About toolBar
I add a button on a JToolBar. The color is different from the button in a JPanel. For example, see the following program:
JToolBar toolBar =new JToolBar();
JPanel panel =new JPanel();
panel.add(new JButton("button"));
toolBar.add(new JButton("button"));
toolBar.add(panel);
JFrame frame =new JFrame();
frame.setLayout(new FlowLayout());
frame.add(toolBar);
frame.setSize(100, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
The toolbar contains one button and a panel which containing a button. The two buttons' color is different. How do I make them look same?
Thanks.
# 6
public class Test{
public static void main(String []args){
JToolBar toolBar = new JToolBar();
JPanel panel = new JPanel();
panel.add(new JButton("button"));
toolBar.add(new JButton("button"));
toolBar.add(panel);
JFrame frame = new JFrame();
frame.setLayout(new FlowLayout());
frame.add(toolBar);
frame.setSize(100, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
# 7
One of these days you should actually try answering questions instead of just asking them.
I still can't copy, paste and compile the code. There are no import statements. Most of us spend time answering multiple questions on the forum and don't want to be bothered with trying to figure out what import statements are required.
Anyway, the code works fine using JDK1.4.2 on XP. The buttons are the same color.
I suggest you list the specifics of your machine and maybe someone else using the same setup will test the code.