I thought that calling setEnabled() on a JSplitPane object will also enable/disable the divider buttons. I found out it does not. Only the divider gets disabled so when you click on the buttons, the JSplitPane will still be resized.

To get a reference on the buttons, you make use of the BasicSplitPaneUI class, cast it and call setEnabled() on them.

Check the code below.

That should let you enable or disable the buttons of the JSplitPane divider.


Creating a logout button beside a set of tabbed panes in a JTabbedPane like the image pictured above can only be done by adding another tabbed pane and overriding the pane’s UI methods to remove the borders of the last tabbed pane while setting the location of the logout button to the far right.

If you do not override the UI methods of the JTabbedPane, the tabbed pane’s borders will always be visible plus the logout button will always be positioned next to the other tabbed panes instead of to the far right.

I had a previous post regarding rotating a JLabel and that involved creating a class that extends the BasicLabelUI class to do the rotation. JButton also has a class of its own called BasicButtonUI that you need to inherit in order to do rotation vertically.

To set the JButton to a certain angle, just set the parameter as either 90 or 270 in the VerticalButtonUI class. Kudos to the developer who created this class (I don’t know who).

Here is the code for the VerticalButtonUI class.

Related Posts Plugin for WordPress, Blogger...