-
Bug
-
Resolution: Unresolved
-
P4
-
6u24
-
x86
-
linux
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) 64-Bit Server VM (build 16.2-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux Miguel 2.6.18-194.17.1.el5 #1 SMP Mon Sep 20 07:12:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When I use JButtons for labels on a JSlider, the buttons at the top and the bottom get cut off. This problem only shows up in Nimbus.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the enclosed program. Try it in various looks-and-feels using the buttons on the left.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JButtons should all draw correctly, including their entire border.
ACTUAL -
In all L&Fs except Nimbus, they draw correctly. In Nimbus, the top and bottom buttons are clipped and fail to show their full borders. It looks very unprofessional and is therefore unusable.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.metal.*;
/**
* <p>Created by IntelliJ IDEA.
* <p>Date: 4/7/11
* <p>Time: 1:41 PM
*
* @author Miguel Mu\u00f1oz
*/
@SuppressWarnings({"HardCodedStringLiteral"})
public class Sliderbug extends JPanel {
private Sliderbug() {
super(new GridLayout(1, 0));
int max = 3;
JSlider slider = makeSlider(max);
add(slider, BorderLayout.CENTER);
setBorder(new MatteBorder(10, 10, 10, 10, getBackground()));
}
private static JSlider makeSlider(int max) {
JSlider slider = new JSlider(JSlider.VERTICAL, 0, max, 0);
Dictionary<Integer, JComponent> dictionary = makeDicitonary(max);
slider.setLabelTable(dictionary);
slider.setPaintLabels(true);
slider.setInverted(true);
return slider;
}
private static Dictionary<Integer, JComponent> makeDicitonary(int max) {
@SuppressWarnings({"UseOfObsoleteCollectionType"})
Dictionary<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
for (int ii=0; ii<=max; ++ii) {
dictionary.put(ii, new JButton("Button " + ii));
}
return dictionary;
}
public static void main(String[] args) {
showFrame(SLIDER_BUG);
}
private static final String SLIDER_BUG = "Slider Bug";
@SuppressWarnings({"StaticVariableMayNotBeInitialized"})
private static JFrame frame;
private static JFrame createFrame(String name) {
JFrame localFrame = new JFrame(name);
JPanel lfPanel = new JPanel(new BorderLayout());
JPanel lfGrid = new JPanel(new GridLayout(0, 1, 5, 5));
for (final LF lf: LF.values()) {
JButton btn = new JButton(lf.toString());
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
lf.setLf();
frame.dispose();
showFrame(frame.getTitle());
}
});
lfGrid.add(btn);
}
lfPanel.add(lfGrid, BorderLayout.PAGE_START);
localFrame.add(lfPanel, BorderLayout.LINE_START);
localFrame.add(new Sliderbug(), BorderLayout.CENTER);
return localFrame;
}
private static void showFrame(String title) {
frame = createFrame(title);
frame.pack();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
private enum LF {
Nimbus("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"),
Metal("javax.swing.plaf.metal.MetalLookAndFeel", new DefaultMetalTheme()),
Ocean("javax.swing.plaf.metal.MetalLookAndFeel", new OceanTheme()),
Motif("com.sun.java.swing.plaf.motif.MotifLookAndFeel"),
Platform(UIManager.getSystemLookAndFeelClassName()),
CrossPlatform(UIManager.getCrossPlatformLookAndFeelClassName()),
;
private final String name;
private final MetalTheme theme;
LF(String s) {
this(s, null);
}
LF(String s, MetalTheme theme) {
this.name=s;
this.theme = theme;
}
public void setLf() {
if (theme != null) {
MetalLookAndFeel.setCurrentTheme(theme);
} else {
if (name.contains("Metal")) {
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
}
}
//noinspection OverlyBroadCatchBlock
try {
UIManager.setLookAndFeel(name);
} catch (Exception ignored) { }
}
}
}
---------- END SOURCE ----------
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) 64-Bit Server VM (build 16.2-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux Miguel 2.6.18-194.17.1.el5 #1 SMP Mon Sep 20 07:12:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When I use JButtons for labels on a JSlider, the buttons at the top and the bottom get cut off. This problem only shows up in Nimbus.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the enclosed program. Try it in various looks-and-feels using the buttons on the left.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JButtons should all draw correctly, including their entire border.
ACTUAL -
In all L&Fs except Nimbus, they draw correctly. In Nimbus, the top and bottom buttons are clipped and fail to show their full borders. It looks very unprofessional and is therefore unusable.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.metal.*;
/**
* <p>Created by IntelliJ IDEA.
* <p>Date: 4/7/11
* <p>Time: 1:41 PM
*
* @author Miguel Mu\u00f1oz
*/
@SuppressWarnings({"HardCodedStringLiteral"})
public class Sliderbug extends JPanel {
private Sliderbug() {
super(new GridLayout(1, 0));
int max = 3;
JSlider slider = makeSlider(max);
add(slider, BorderLayout.CENTER);
setBorder(new MatteBorder(10, 10, 10, 10, getBackground()));
}
private static JSlider makeSlider(int max) {
JSlider slider = new JSlider(JSlider.VERTICAL, 0, max, 0);
Dictionary<Integer, JComponent> dictionary = makeDicitonary(max);
slider.setLabelTable(dictionary);
slider.setPaintLabels(true);
slider.setInverted(true);
return slider;
}
private static Dictionary<Integer, JComponent> makeDicitonary(int max) {
@SuppressWarnings({"UseOfObsoleteCollectionType"})
Dictionary<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
for (int ii=0; ii<=max; ++ii) {
dictionary.put(ii, new JButton("Button " + ii));
}
return dictionary;
}
public static void main(String[] args) {
showFrame(SLIDER_BUG);
}
private static final String SLIDER_BUG = "Slider Bug";
@SuppressWarnings({"StaticVariableMayNotBeInitialized"})
private static JFrame frame;
private static JFrame createFrame(String name) {
JFrame localFrame = new JFrame(name);
JPanel lfPanel = new JPanel(new BorderLayout());
JPanel lfGrid = new JPanel(new GridLayout(0, 1, 5, 5));
for (final LF lf: LF.values()) {
JButton btn = new JButton(lf.toString());
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
lf.setLf();
frame.dispose();
showFrame(frame.getTitle());
}
});
lfGrid.add(btn);
}
lfPanel.add(lfGrid, BorderLayout.PAGE_START);
localFrame.add(lfPanel, BorderLayout.LINE_START);
localFrame.add(new Sliderbug(), BorderLayout.CENTER);
return localFrame;
}
private static void showFrame(String title) {
frame = createFrame(title);
frame.pack();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
private enum LF {
Nimbus("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"),
Metal("javax.swing.plaf.metal.MetalLookAndFeel", new DefaultMetalTheme()),
Ocean("javax.swing.plaf.metal.MetalLookAndFeel", new OceanTheme()),
Motif("com.sun.java.swing.plaf.motif.MotifLookAndFeel"),
Platform(UIManager.getSystemLookAndFeelClassName()),
CrossPlatform(UIManager.getCrossPlatformLookAndFeelClassName()),
;
private final String name;
private final MetalTheme theme;
LF(String s) {
this(s, null);
}
LF(String s, MetalTheme theme) {
this.name=s;
this.theme = theme;
}
public void setLf() {
if (theme != null) {
MetalLookAndFeel.setCurrentTheme(theme);
} else {
if (name.contains("Metal")) {
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
}
}
//noinspection OverlyBroadCatchBlock
try {
UIManager.setLookAndFeel(name);
} catch (Exception ignored) { }
}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-5052372 Truncated JSlider labels when longer
- Resolved