Pop-up window in Java Swing

前端 未结 3 824
囚心锁ツ
囚心锁ツ 2021-01-12 10:44

Can someone suggest me how to implement a pop-up window in Java Swing. I want the pop-up window to be a modal window (user cannot return to the main window when the pop-up i

相关标签:
3条回答
  • 2021-01-12 11:07

    Use a JDialog. There is no restiction on what you can add, you can add whatever you want to a JDialog (exactly the same as when using a JFrame)

    0 讨论(0)
  • 2021-01-12 11:07
    1. Layout your widgets in a JPanel.

    2. Use JOptionPane.showConfirmDialog with your panel as the message (with, for example, optionType JOptionPane.OK_CANCEL_OPTION).

    3. Read user input from your panel's state when appropriate (for example, the call returns JOptionPane.OK_OPTION rather than JOptionPane.CANCEL_OPTION).

    0 讨论(0)
  • 2021-01-12 11:30

    I hope i found the right info for you

    JDialog(Dialog owner, boolean modal)

    for more information check this links: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/modality/

    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

    0 讨论(0)
提交回复
热议问题