-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
None
-
generic
-
generic
Popup menus in Modal dialogs get cut off at the dialog border:
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJMenu05 extends JFrame implements ActionListener {
/*************************************** Bug Description ***************************************/
String[] strBugDesc = { "",
"",
"",
"",
"This TestCase tests the JDialog Component and JMenu Component",
"**Problem** : JMenu menu items not fully visible when used in a JDialog",
"",
"Steps to reproduce :",
"1. Click on menu 'Does Nothing JMenuItem'. -- this works properly when in a JFrame.",
"2. Click on 'Show the Dialog' button. -- this brings up a dialog.",
"3. Click on menu 'Does Nothing JMenuItem' in the dialog. -- All the menuitems are not visible.",
"4. Increase the size of the the dialog to more than the size of the menuitems when dropped down.",
"5. Click on menu 'Does Nothing JMenuItem' in the dialog. -- Now all the menuitems are visible.",
"",
"Pass/Fail Criteria : ",
"Pass -- Click on menu 'Does Nothing JMenuItem' in the dialog before resizing the dialog. -- All the menuitems should be visible.",
"",
"",
"",
""};
/*************************************** Bug Description ***************************************/
Container content;
JPanel panel;
JDialog dialog;
JButton bn;
TestJMenu05(String[] args) {
displayBugDesc();
content = getContentPane();
content.setLayout(new BorderLayout());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event){
System.exit(0);
}
}
);
panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(bn = new JButton("Show the Dialog"));
bn.addActionListener(this);
panel.add(getMyMenuBar());
content.add("Center", panel);
pack();
show();
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Show the Dialog")) {
dialog = new JDialog(TestJMenu05.this, "Testing the Dailog", true);
dialog.getContentPane().add("South", new JButton("Simple Button in the Dialog. Does Nothing!!"));
dialog.getContentPane().add("North", getMyMenuBar());
dialog.setLocationRelativeTo(null);
dialog.pack();
dialog.show();
}
}
public JMenuBar getMyMenuBar() {
JMenuBar menubar;
JMenu menu;
JMenuItem menuitem;
JCheckBoxMenuItem cbmItem;
JRadioButtonMenuItem rbmItem;
menubar = new JMenuBar();
menu = new JMenu("Does nothing JMenuItem");
menu.setMnemonic('M');
for(int i = 0; i < 10; i ++ ) {
menuitem = new JMenuItem("JMenuItem" + i);
menuitem.setMnemonic('0' + i);
menu.add(menuitem);
}
menubar.add(menu);
return menubar;
}
public void displayBugDesc() {
int n = strBugDesc.length;
System.out.println("/******************************* Bug Description and Comments *******************************/");
System.out.println();
for(int i = 0; i < n; i ++) {
System.out.println(strBugDesc[i]);
}
System.out.println();
System.out.println("/******************************* Bug Description and Comments *******************************/");
}
// Main funtion
public static void main(String[] args) {
TestJMenu05 TestJMenu05 = new TestJMenu05(args);
}
}
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJMenu05 extends JFrame implements ActionListener {
/*************************************** Bug Description ***************************************/
String[] strBugDesc = { "",
"",
"",
"",
"This TestCase tests the JDialog Component and JMenu Component",
"**Problem** : JMenu menu items not fully visible when used in a JDialog",
"",
"Steps to reproduce :",
"1. Click on menu 'Does Nothing JMenuItem'. -- this works properly when in a JFrame.",
"2. Click on 'Show the Dialog' button. -- this brings up a dialog.",
"3. Click on menu 'Does Nothing JMenuItem' in the dialog. -- All the menuitems are not visible.",
"4. Increase the size of the the dialog to more than the size of the menuitems when dropped down.",
"5. Click on menu 'Does Nothing JMenuItem' in the dialog. -- Now all the menuitems are visible.",
"",
"Pass/Fail Criteria : ",
"Pass -- Click on menu 'Does Nothing JMenuItem' in the dialog before resizing the dialog. -- All the menuitems should be visible.",
"",
"",
"",
""};
/*************************************** Bug Description ***************************************/
Container content;
JPanel panel;
JDialog dialog;
JButton bn;
TestJMenu05(String[] args) {
displayBugDesc();
content = getContentPane();
content.setLayout(new BorderLayout());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event){
System.exit(0);
}
}
);
panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(bn = new JButton("Show the Dialog"));
bn.addActionListener(this);
panel.add(getMyMenuBar());
content.add("Center", panel);
pack();
show();
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Show the Dialog")) {
dialog = new JDialog(TestJMenu05.this, "Testing the Dailog", true);
dialog.getContentPane().add("South", new JButton("Simple Button in the Dialog. Does Nothing!!"));
dialog.getContentPane().add("North", getMyMenuBar());
dialog.setLocationRelativeTo(null);
dialog.pack();
dialog.show();
}
}
public JMenuBar getMyMenuBar() {
JMenuBar menubar;
JMenu menu;
JMenuItem menuitem;
JCheckBoxMenuItem cbmItem;
JRadioButtonMenuItem rbmItem;
menubar = new JMenuBar();
menu = new JMenu("Does nothing JMenuItem");
menu.setMnemonic('M');
for(int i = 0; i < 10; i ++ ) {
menuitem = new JMenuItem("JMenuItem" + i);
menuitem.setMnemonic('0' + i);
menu.add(menuitem);
}
menubar.add(menu);
return menubar;
}
public void displayBugDesc() {
int n = strBugDesc.length;
System.out.println("/******************************* Bug Description and Comments *******************************/");
System.out.println();
for(int i = 0; i < n; i ++) {
System.out.println(strBugDesc[i]);
}
System.out.println();
System.out.println("/******************************* Bug Description and Comments *******************************/");
}
// Main funtion
public static void main(String[] args) {
TestJMenu05 TestJMenu05 = new TestJMenu05(args);
}
}
- duplicates
-
JDK-4243866 JPopupMenus are clipped by modal dialogs but not non-modal dialogs
- Resolved
- relates to
-
JDK-4108761 JMenuItems not completly visible when in JDialog.
- Resolved