Package: javax.swing.* |
Product: Swing |
Release: 1.0.3 |
Related Links: |
ComboBox
JDialog
JFileChooser
JFrame
JOptionPane
JProgressBar
JScrollPane
JTable
General
JTree
JWindow
KeyStroke
LayeredPane
UIDefaults
|
Comment: |
JScrollPane sp = new JScrollPane(); sp.getHorizontalScrollBar().addAdjustmentListener( new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { dbg("adjust: " + ae); dbg("source: " + ae.getSource()); if ( ae.getSource() instanceof JScrollBar) { ((JScrollBar) ae.getSource()).setValue(0); } } }); // // Declare: public AdjustmentListener al = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { System.out.println("doReset=" + doReset +", " + ae.paramString() ); if (doReset) { System.out.println("RESET =" + ae); doReset = false; ((JScrollBar) ae.getSource()).setValue(0); doReset = false; } //} } }; private static boolean doReset = true; void init() { JScrollPane sp = new JScrollPane(); sp.getHorizontalScrollBar().addAdjustmentListener(al); setScrollList(sp); } /* Some Event like TreeExpansion, TreeCollapse etc.. With invoke this method */ void align() { doReset = true; } |