Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1794

Re: Update GUI while JSli

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: Update GUI while JSli
Message-ID <73877a162cd8e@uwe> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1181544065_2266@sicinfo3.epfl.ch>
References <1181544065_2266@sicinfo3.epfl.ch>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 60
Date Wed, 27 Apr 2011 15:35:23 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918523 96.60.20.240 (Wed, 27 Apr 2011 10:35:23 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:35:23 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1794

Show key headers only | View raw


  To: comp.lang.java.gui
Philipp wrote:
>Knute Johnson a |-crit :
..
> > You need to take a look at JSlider.getValueIsAdjusting().  
..
>How could I implement that? 

<sscce>
import javax.swing.*;
import javax.swing.event.*;

public class SliderValue
  extends JPanel
  implements ChangeListener {

  JSlider slider;
  JLabel message;

  SliderValue() {
    super(new java.awt.GridLayout(0,1));
    slider = new JSlider(1,100);
    slider.addChangeListener( this );

    message = new JLabel( "50" );

    add(slider);
    add(message);
  }

  /** The ChangeEvents will be continuously dumped
  to the JLabel, but we only want the pop-up
  (animation speed, ..whatever) to be updated/appear
  once the user has *released* the slider. */
  public void stateChanged(ChangeEvent ce) {
    message.setText( "" + slider.getValue() );
    if ( !slider.getValueIsAdjusting() ) {
      JOptionPane.showMessageDialog(null,
        "Value selected: " + slider.getValue() );
    }
  }

  public static void main(String[] args) {
    SliderValue sv = new SliderValue();
    JOptionPane.showMessageDialog( null, sv );
  }
}
</sscce>

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200706/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Update GUI while JSlider "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: Update GUI while JSli "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: Update GUI while JSli "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: Update GUI while JSli "Chris Smith" <chris.smith@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
    Re: Update GUI while JSli "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000

csiph-web