Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Intermediate
Sep 10, 2001



Application Security Testing: An Integral Part of DevOps

Use Mouse Wheel to Control JSpinner

Merlin (JDK1.4) introduces two new features: JSpinner and MouseWheelListener. Sometimes it is convenient to control the spinner values with the mouse wheel. Here's an example:
import javax.swing.*;
import java.awt.event.*;
public class TestSpinner extends JFrame implements 
  public TestSpinner()
    setSize( 100, 50 );
    spinner = new JSpinner();
    spinner.addMouseWheelListener( this );
    getContentPane().add( spinner, "Center" );
  public void mouseWheelMoved( MouseWheelEvent e )
    spinner.setValue( new Integer( 
((Integer)spinner.getValue()).intValue() - 
e.getWheelRotation() ) );
  public static void main( String [] args )
    TestSpinner t = new TestSpinner();
    t.setVisible( true );
  private JSpinner spinner;
Leslie Lu
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date