Details
-
Bug
-
Resolution: Fixed
-
P3
-
6, 6u65
-
b15
-
sparc
-
solaris
-
Verified
Description
Description:
On GTK Look and Feel, the current value of the JSlider got overlapped on the border attached to it.
Steps to reproduce:
1. Run the attached code
2. A JFrame with a JSlider and JComboBox will be displayed
3. Now select the "GTk" LAF in the combobox
4. Now you can see the Current value of the JSlider get displayed over the Border.
Sample code:
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class JSliderBug extends JFrame implements ActionListener {
private JComboBox lafCombo;
private JSlider fontSizeSlider = new JSlider(JSlider.HORIZONTAL, 10, 30, 12);
public JSliderBug() {
super("JSliderBug");
lafCombo = new JComboBox(new String[] {"Ocean",
"Windows",
"Motif",
"GTK"});
lafCombo.addActionListener(this);
getContentPane().add(lafCombo, BorderLayout.SOUTH);
fontSizeSlider.setMajorTickSpacing(5);
fontSizeSlider.setMinorTickSpacing(1);
fontSizeSlider.setPaintTicks(true);
fontSizeSlider.setPaintLabels(true);
fontSizeSlider.setBorder(BorderFactory.createTitledBorder(new BevelBorder(BevelBorder.LOWERED), "Font Size"));
fontSizeSlider.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent ce) {
JSlider source = (JSlider)ce.getSource();
if(!source.getValueIsAdjusting()) {
int value = (int)source.getValue();
System.out.println("Selected value "+value);
}
return;
}
});
JPanel sliderPanel = new JPanel();
sliderPanel.add(fontSizeSlider);
getContentPane().add(sliderPanel);
}
public static void main(String args[]) {
JSliderBug demo = new JSliderBug();
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
demo.setSize(600, 400);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
demo.setLocationRelativeTo(null);
demo.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
Object source = ae.getSource();
if( source == lafCombo)
changeLAF();
}
private void changeLAF() {
Object val = lafCombo.getSelectedItem();
String className = null;
javax.swing.plaf.metal.MetalTheme theme = null;
if (val == "Ocean") {
className = "javax.swing.plaf.metal.MetalLookAndFeel";
theme = new javax.swing.plaf.metal.OceanTheme();
} else if (val == "Windows") {
className = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else if (val == "Motif") {
className = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if (val == "GTK") {
className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
}
try {
if (theme != null) {
javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(theme);
}
UIManager.setLookAndFeel(className);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Build:
java -version
java version "1.6.0-swing_int_awt_blade"
Java(TM) SE Runtime Environment (build 1.6.0-swing_int_awt_blade-jcg-integrator_22_Mar_2006_12_35-b00)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b76, mixed mode)
This behavior is same with JDK 1.5 also.
Apart from this, the labels are displayed over the border's lower portion on GTK LAF. In case of the other look and feel, it's displayed properly.
Please see the attached image for more details.
This bug is applicable for the Vertical Slider too.
On GTK Look and Feel, the current value of the JSlider got overlapped on the border attached to it.
Steps to reproduce:
1. Run the attached code
2. A JFrame with a JSlider and JComboBox will be displayed
3. Now select the "GTk" LAF in the combobox
4. Now you can see the Current value of the JSlider get displayed over the Border.
Sample code:
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class JSliderBug extends JFrame implements ActionListener {
private JComboBox lafCombo;
private JSlider fontSizeSlider = new JSlider(JSlider.HORIZONTAL, 10, 30, 12);
public JSliderBug() {
super("JSliderBug");
lafCombo = new JComboBox(new String[] {"Ocean",
"Windows",
"Motif",
"GTK"});
lafCombo.addActionListener(this);
getContentPane().add(lafCombo, BorderLayout.SOUTH);
fontSizeSlider.setMajorTickSpacing(5);
fontSizeSlider.setMinorTickSpacing(1);
fontSizeSlider.setPaintTicks(true);
fontSizeSlider.setPaintLabels(true);
fontSizeSlider.setBorder(BorderFactory.createTitledBorder(new BevelBorder(BevelBorder.LOWERED), "Font Size"));
fontSizeSlider.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent ce) {
JSlider source = (JSlider)ce.getSource();
if(!source.getValueIsAdjusting()) {
int value = (int)source.getValue();
System.out.println("Selected value "+value);
}
return;
}
});
JPanel sliderPanel = new JPanel();
sliderPanel.add(fontSizeSlider);
getContentPane().add(sliderPanel);
}
public static void main(String args[]) {
JSliderBug demo = new JSliderBug();
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
demo.setSize(600, 400);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
demo.setLocationRelativeTo(null);
demo.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
Object source = ae.getSource();
if( source == lafCombo)
changeLAF();
}
private void changeLAF() {
Object val = lafCombo.getSelectedItem();
String className = null;
javax.swing.plaf.metal.MetalTheme theme = null;
if (val == "Ocean") {
className = "javax.swing.plaf.metal.MetalLookAndFeel";
theme = new javax.swing.plaf.metal.OceanTheme();
} else if (val == "Windows") {
className = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else if (val == "Motif") {
className = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if (val == "GTK") {
className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
}
try {
if (theme != null) {
javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(theme);
}
UIManager.setLookAndFeel(className);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Build:
java -version
java version "1.6.0-swing_int_awt_blade"
Java(TM) SE Runtime Environment (build 1.6.0-swing_int_awt_blade-jcg-integrator_22_Mar_2006_12_35-b00)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b76, mixed mode)
This behavior is same with JDK 1.5 also.
Apart from this, the labels are displayed over the border's lower portion on GTK LAF. In case of the other look and feel, it's displayed properly.
Please see the attached image for more details.
This bug is applicable for the Vertical Slider too.