-
Bug
-
Resolution: Fixed
-
P2
-
1.1.5
-
None
-
1.1.5
-
unknown
-
solaris_2.5.1
-
Not verified
/*
From: David Geary <###@###.###>
To: swing feedback <###@###.###>
Subject: Bug: JSlider Jumps After Dragging
Date: Fri, 14 Nov 1997 22:01:16 -0600
JSliders seem to jump a slight bit after they are dragged. You can see
the effect with the SwingSet demo, but I've also included an application
that seems to exhibit the bug more reliably.
Verified on swing-0.5.1 with Windows L&F and swing0.6 with
JLF.
*/
/* setenv JDKHOME /home/hmuller/ws/jdk12/build/solaris
* ${JDKHOME}/bin/javac -classpath ${JDKHOME}/classes SliderBug.java
* ${JDKHOME}/bin/java -classpath .:${JDKHOME}/classes SliderBug
*/
/* setenv JDKHOME /usr/local/java/jdk1.1.5/solaris
* setenv SWINGJAR /usr/local/java/swing-0.5.1/swing.jar
* ${JDKHOME}/bin/javac -classpath ${SWINGJAR}:${JDKHOME}/lib/classes.zip SliderBug.java
* ${JDKHOME}/bin/java -classpath .:${SWINGJAR}:${JDKHOME}/lib/classes.zip SliderBug
*/
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class SliderBug extends JFrame
{
private JSlider slider = new JSlider();
public SliderBug() {
Container cp = getContentPane();
cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
cp.add(makeControlPanel());
cp.add(slider);
DebugGraphics.setFlashCount(1);
}
private JPanel makeControlPanel() {
JPanel controlPanel = new JPanel();
JButton repaintButton = new JButton("repaint");
final JSlider flashTimeSlider =
new JSlider(JSlider.HORIZONTAL,0,500,100);
flashTimeSlider.setPaintTicks(true);
flashTimeSlider.setMajorTickSpacing(10);
flashTimeSlider.setMinorTickSpacing(5);
flashTimeSlider.setBorder(
BorderFactory.createTitledBorder("Flash Time"));
controlPanel.setBorder(
BorderFactory.createTitledBorder("Controls"));
controlPanel.setLayout(
new BoxLayout(controlPanel, BoxLayout.X_AXIS));
controlPanel.add(repaintButton);
controlPanel.add(flashTimeSlider);
repaintButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int opts = slider.getDebugGraphicsOptions();
if(opts != DebugGraphics.FLASH_OPTION) {
slider.setDebugGraphicsOptions(
DebugGraphics.FLASH_OPTION);
}
SliderBug.this.repaint();
}
});
flashTimeSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
DebugGraphics.setFlashTime(
flashTimeSlider.getValue());
}
});
return controlPanel;
}
public static void main(String args[]) {
/*
try {
UIManager.setLookAndFeel("com.sun.java.swing/jlf/JLFLookAndFeel");
}
catch (Exception e) {
e.printStackTrace();
}
*/
final JFrame f = new SliderBug();
f.setBounds(100,100,300,150);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
f.dispose();
System.exit(0);
}
});
}
}