How to disable JSplitPane arrow button
How do I disable(grey-out) the arrow button on the JSplitPane. I do know how to get the button from BasicSplitPaneDivider like this:
final int UP_ARROW = 0; final BasicSplitPaneUI ui = (BasicSplitPaneUI) splitPane.getUI(); final BasicSplitPaneDivider divider = ui.getDi开发者_开发百科vider(); final JButton upArrowButton = (JButton) divider.getComponent(UP_ARROW);
, but when I try upArrowButton.setEnabled(false)
, it doesn't grey-out the up arrow, but does disable it. I want the user to have a visual feedback that the up arrow button is disabled. I did try upArrowButton.getAction().setEnabled(false)
, but it doesn't work(NullPointerException).
Please help
Have you tried setOneTouchExpandable(false)
?
final int UP_ARROW = 0;
final BasicSplitPaneUI ui = (BasicSplitPaneUI) splitPane.getUI();
final BasicSplitPaneDivider divider = ui.getDivider();
final JButton upArrowButton = (JButton) divider.getComponent(UP_ARROW);
upArrowButton.setVisible(false);
This work for me
精彩评论