studio.ui.EscapeDialog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kdbStudio Show documentation
Show all versions of kdbStudio Show documentation
Studio for kdb+ is a rapid development environment for the ultra-fast database kdb+ from Kx Systems: http://www.kx.com.
package studio.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public abstract class EscapeDialog extends JDialog {
public enum DialogResult {ACCEPTED, CANCELLED};
private DialogResult result = DialogResult.CANCELLED;
public EscapeDialog(Window owner,String title) {
super(owner,title, ModalityType.APPLICATION_MODAL);
initComponents();
}
public void align() {
pack();
Util.centerChildOnParent(this, getParent());
}
public void alignAndShow() {
align();
setVisible(true);
}
private void initComponents() {
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
this.getRootPane().registerKeyboardAction(e->cancel(), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
public void cancel() {
result = DialogResult.CANCELLED;
dispose();
}
public void accept() {
result = DialogResult.ACCEPTED;
dispose();
}
public DialogResult getResult() {
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy