-
Bug
-
Resolution: Fixed
-
P4
-
1.1.5, 1.2.0
-
swing2.0alpha
-
x86, sparc
-
solaris_2.6, windows_95
JMenuItems are not fully visible when in a JDialog. When clicked on a menu, only the items till the height of the dialog are visible. So if the size of the dialog < the size of the menu items when dropped down, the menuitems get cropped.
Sample code is provided below for the same...
Steps to simulate the same...
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.
-- Sample Code --
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import com.sun.java.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");
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);
}
}
-- Sample Code --
Sample code is provided below for the same...
Steps to simulate the same...
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.
-- Sample Code --
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import com.sun.java.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");
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);
}
}
-- Sample Code --
- relates to
-
JDK-4178531 Use new 1.2 APIs to allow PopupMenus for Modal Dialogs
-
- Closed
-