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);
}
}

Reply via email to