Akochai - Attached are some modifications to your file. Please check out my comments, especially in the last method.
Why do you want to add a button to a menu? Isn't that what a menu item is anyway? - Keith Bennett -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of akokchai Sent: Tuesday, February 12, 2002 5:13 PM To: [EMAIL PROTECTED] Subject: How to display JPopupMenu properly (size) in model JDialog box? The size of the PopupMenu is 1000,1000. but it can't show entire. I know it's because it's in the model JDialog. But I don't know how to solve it.. Please help me.. Thank you. public class PopupMenuFrame extends javax.swing.JFrame { public PopupMenuFrame() { super(); java.awt.Container c = getContentPane(); c.setLayout(new java.awt.BorderLayout()); javax.swing.JButton button = new javax.swing.JButton("Click me"); button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { showOptionPane(); } }); c.add(java.awt.BorderLayout.CENTER, button); } public static void main(String[] args) { PopupMenuFrame frame = new PopupMenuFrame(); frame.setSize(new java.awt.Dimension(200,200)); frame.setVisible(true); } private void showOptionPane() { final javax.swing.JPanel pane = new javax.swing.JPanel(); pane.setLayout(new java.awt.BorderLayout()); javax.swing.JButton button = new javax.swing.JButton("Click me"); button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { showPopupMenu(pane); } }); pane.add(java.awt.BorderLayout.CENTER, button); javax.swing.JOptionPane.showConfirmDialog(this, pane); } private void showPopupMenu(java.awt.Component c) { javax.swing.JPopupMenu menu = new javax.swing.JPopupMenu(); javax.swing.JButton button = new javax.swing.JButton(); button.setPreferredSize(new java.awt.Dimension(1000,1000)); menu.add(button); menu.show(c, 0, 0); } }
PopupMenuFrame.java
Description: Binary data