Reputation: 202
I have a question regarding the usage of actionListener for the title of a TitledBorder:
borderPanel1 = BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
MainFrame.windowTitle);
My final goal is to be able to press the title of the border to change the title of a panel. How would I be able to add some kind of Listener to the title of this border?
Upvotes: 1
Views: 387
Reputation: 205785
The authors of setBorder()
"recommend that you put the component in a JPanel
and set the border on the JPanel
." You could add a MouseAdapter
to that JPanel
and have the chosen handler bring up the Preferences
dialog, as @Catalina Island suggests.
Upvotes: 2
Reputation: 7126
A titled border really isn't designed for this; it's a Border
, not a Component
. If the title is a user preference, the you can add it to your Preferences
dialog.
Upvotes: 2