-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
2.1, 1.1.1, 1.1.6
-
None
-
generic, x86
-
other, solaris_2.6, windows_nt
The following code demonstrates a problem with displaying large menus.
import java.awt.*;
import java.awt.event.*;
public class MenuTest extends Frame {
MenuBar menuTest;
public MenuTest() {
super();
setSize(200,200);
this.addWindowListener(new WindowAdapter() { // begin anon
public void windowClosing(WindowEvent e) {
System.exit(0);
} // windowClosing
} ); // end anon
menuTest = createMenuBar();
}
// basic instantiation
public static void main(String argv[]) {
MenuTest testFrame = new MenuTest();
testFrame.setMenuBar(testFrame.menuTest);
testFrame.setVisible(true);
}
MenuBar createMenuBar() {
// MenuBar
MenuBar menuBar = new MenuBar();
MenuItem mi;
// File Menu
Menu file = (Menu) menuBar.add(new Menu("File"));
mi = (MenuItem) file.add(new MenuItem("About"));
mi = (MenuItem) file.add(new MenuItem("Open"));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Save"));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Save As..."));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Exit"));
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
// Options Menu
Menu options = (Menu) menuBar.add(new Menu("100 Items"));
for (int i = 1; i<100; i++)
{
mi = (MenuItem) options.add(new MenuItem("choice " + i));
}
return menuBar;
}
}
Added by nick.rodin@eng, 1998-10-19:
I have tested this example with 1.1.6, 1.1.7, and 1.2 with the same results.
import java.awt.*;
import java.awt.event.*;
public class MenuTest extends Frame {
MenuBar menuTest;
public MenuTest() {
super();
setSize(200,200);
this.addWindowListener(new WindowAdapter() { // begin anon
public void windowClosing(WindowEvent e) {
System.exit(0);
} // windowClosing
} ); // end anon
menuTest = createMenuBar();
}
// basic instantiation
public static void main(String argv[]) {
MenuTest testFrame = new MenuTest();
testFrame.setMenuBar(testFrame.menuTest);
testFrame.setVisible(true);
}
MenuBar createMenuBar() {
// MenuBar
MenuBar menuBar = new MenuBar();
MenuItem mi;
// File Menu
Menu file = (Menu) menuBar.add(new Menu("File"));
mi = (MenuItem) file.add(new MenuItem("About"));
mi = (MenuItem) file.add(new MenuItem("Open"));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Save"));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Save As..."));
mi.setEnabled(false);
mi = (MenuItem) file.add(new MenuItem("Exit"));
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
// Options Menu
Menu options = (Menu) menuBar.add(new Menu("100 Items"));
for (int i = 1; i<100; i++)
{
mi = (MenuItem) options.add(new MenuItem("choice " + i));
}
return menuBar;
}
}
Added by nick.rodin@eng, 1998-10-19:
I have tested this example with 1.1.6, 1.1.7, and 1.2 with the same results.
- duplicates
-
JDK-4173413 JCT - the pop up menu does not have the scrolling function
- Closed
-
JDK-4179758 Menus should have scrollbars when there are many menu items
- Closed
- relates to
-
JDK-4073305 Popup menus can go off screen
- Closed