Java Code Examples for javax.swing.WindowConstants#DISPOSE_ON_CLOSE

The following examples show how to use javax.swing.WindowConstants#DISPOSE_ON_CLOSE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutDialog.java    From Girinoscope with Apache License 2.0 6 votes vote down vote up
public AboutDialog(JFrame owner) {
    super(owner, true);
    super.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    super.setLayout(new BorderLayout());
    super.setBackground(Color.WHITE);

    try {
        HtmlPane htmlPane = new HtmlPane(AboutDialog.class.getResource("about.html"));
        htmlPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
        htmlPane.setOpaque(true);
        super.add(htmlPane, BorderLayout.CENTER);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    super.pack();
    super.setLocationRelativeTo(owner);
    super.setResizable(false);

    DialogHelper.installEscapeCloseOperation(AboutDialog.this);
}
 
Example 2
Source File: CustomAxisEditionDialog.java    From Girinoscope with Apache License 2.0 6 votes vote down vote up
private CustomAxisEditionDialog(JFrame owner, Axis.Builder axisBuilder) {
    super(owner, true);
    this.axisBuilder = axisBuilder;

    super.setTitle("Y Axis parameters");
    super.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    super.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            CustomAxisEditionDialog.this.axisBuilder = null;
        }
    });

    super.setLayout(new BorderLayout());
    super.setBackground(Color.WHITE);
    super.add(createEditorPane(), BorderLayout.CENTER);
    super.add(createButtonBar(cancelAction, applyAction), BorderLayout.SOUTH);

    super.pack();
    super.setLocationRelativeTo(owner);
    super.setResizable(false);

    DialogHelper.installEscapeCloseOperation(CustomAxisEditionDialog.this);
}
 
Example 3
Source File: WindowMenu.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public void doClose() {
	if (owner instanceof WindowClosable) {
		((WindowClosable) owner).requestClose();
	} else if (owner != null) {
		int action = owner.getDefaultCloseOperation();
		if (action == WindowConstants.EXIT_ON_CLOSE) {
			System.exit(0);
		} else if (action == WindowConstants.HIDE_ON_CLOSE) {
			owner.setVisible(false);
		} else if (action == WindowConstants.DISPOSE_ON_CLOSE) {
			owner.dispose();
		}
	}
}
 
Example 4
Source File: OSPFrame.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Overrides JFrame method. This converts EXIT_ON_CLOSE to DISPOSE_ON_CLOSE
 * and sets the wishesToExit flag.
 *
 * @param  operation the operation
 */
public void setDefaultCloseOperation(int operation) {
  if((operation==JFrame.EXIT_ON_CLOSE)&&OSPRuntime.launchingInSingleVM) {
    operation = WindowConstants.DISPOSE_ON_CLOSE;
    wishesToExit = true;
  }
  try {
    super.setDefaultCloseOperation(operation);
  } catch(Exception ex) {
    // cannot set the default close operation for java applets frames in Java 1.6
  }
}