-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
x86
-
windows_98, windows_nt
Name: krC82822 Date: 06/01/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
The following program opens a JFrame with a JToolBar and two JButtons on it.
The separator between the buttons draws an ugly line with Windows L&F (only).
The first button can be used to change the L&F to verify that.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ToolBarFrame extends JFrame {
public ToolBarFrame() {
JToolBar toolBar = new JToolBar();
JButton button = new JButton("change L&F");
getContentPane().setLayout(new BorderLayout());
getContentPane().add(toolBar, BorderLayout.NORTH);
toolBar.add(button);
toolBar.addSeparator();
toolBar.add(new JButton("foo"));
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String lfName = null;
if (UIManager.getLookAndFeel().getClass().getName().equals
("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) {
lfName = "javax.swing.plaf.metal.MetalLookAndFeel";
} else if (UIManager.getLookAndFeel().getClass().getName().equals
("javax.swing.plaf.metal.MetalLookAndFeel")) {
lfName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else {
lfName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}
try {
UIManager.setLookAndFeel(lfName);
} catch (Exception ex) {
ex.printStackTrace();
}
SwingUtilities.updateComponentTreeUI(ToolBarFrame.this);
ToolBarFrame.this.pack();
}
});
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception ex) {
ex.printStackTrace();
}
ToolBarFrame frame = new ToolBarFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
(Review ID: 125590)
======================================================================