1. 程式人生 > >java swing 彈出對話方塊與父視窗傳值例項

java swing 彈出對話方塊與父視窗傳值例項

 /**
  * Main entry of the class.
  * Note: This class is only created so that you can easily preview the result at runtime.
  * It is not expected to be managed by the designer.
  * You can modify it as you like.
  */
 public static void main(String[] args) {
  installLnF();
  SwingUtilities.invokeLater(new Runnable() {
   @Override
   public void run() {
    test dialog = new test();
    dialog.setDefaultCloseOperation(test.DISPOSE_ON_CLOSE);
    dialog.setTitle("test");
    dialog.setLocationRelativeTo(null);
    dialog.getContentPane().setPreferredSize(dialog.getSize());
    dialog.pack();
    dialog.setVisible(true);
   }
  });
 }
//close
 private void windowWindowClosed(WindowEvent event) {
  
 }