Hi All,
I have a scrollpane with vertical scrollbar set to show as needed (see
snippet below). I'm trying to work out a reliable way of determining
whether the vertical scrollbar is showing. I've tried calls to
isVisible, isShowing
and getVisibleAmount but these always seem to return incorrect values.
Any ideas?
JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
tableSP = new JScrollPane(tablePanel);
tableSP
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
tableSP
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
sp.setLeftComponent(tableSP);
sp.setRightComponent(chartBox);
mainView = new JPanel(new BorderLayout());
mainView.add(sp, BorderLayout.CENTER);
System.out.println(tableSP.getVerticalScrollBar().isVisible());
System.out.println(tableSP.getVerticalScrollBar().isShowing());
System.out.println(tableSP.getVerticalScrollBar().getVisibleAmount());
astrorail - 30 Sep 2004 19:06 GMT
may be u are calling these methods before the GUI is realized or is
hown on the screen
astrorail