Compile and run following codes:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJDK extends JFrame {
int i = 0;
public TestJDK() {
setTitle("Frame");
JMenuBar mBar = new JMenuBar();
JMenu menu = new JMenu("menu1");
JMenuItem item = new JMenuItem("menuitem1");
menu.add(item);
menu.add(new JMenuItem("menuitem2"));
mBar.add(menu);
menu = new JMenu("menu2");
menu.add(new JMenuItem("menuitem1"));
menu.add(new JMenuItem("menuitem2"));
mBar.add(menu);
menu = new JMenu("menu3");
menu.add(new JMenuItem("menuitem1"));
menu.add(new JMenuItem("menuitem2"));
mBar.add(menu);
this.setJMenuBar(mBar);
this.getContentPane().setLayout(new BorderLayout());
pack();
setSize(500,400);
setVisible(true);
}
public static void main(String[] args) {
new TestJDK();
}
}
you will find under jdk1.2, every thing is ok, but under jdk1.4, when we browse menus, there are always some twinkling, it seems the whole frame is refreshed when move menus.