use of java.awt.event.WindowEvent in project processdash by dtuma.
the class HierarchyNoteEditorDialog method constructUserInterface.
private void constructUserInterface() {
loadCustomDimensions();
frame = new JFrame(resources.getString("Window_Title"));
DashboardIconFactory.setWindowIcon(frame);
frame.setSize(new Dimension(frameWidth, frameHeight));
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
confirmClose(true);
}
});
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
PCSH.enableHelpKey(frame, "NoteIndicator");
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, constructTreePanel(), constructEditPanel());
splitPane.setDividerLocation(dividerLocation);
setupWindowKeyBindings(splitPane);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(BorderLayout.CENTER, splitPane);
}
use of java.awt.event.WindowEvent in project processdash by dtuma.
the class AbstractLibraryEditor method buildContents.
private void buildContents() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JPanel panel = new JPanel(layout);
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
Insets insets0 = new Insets(0, 0, 0, 0);
Insets insets10 = new Insets(10, 10, 10, 10);
projectTable = buildJTable(projectModel);
projectTable.setEditingEnabled(false);
JScrollPane sp = new JScrollPane(projectTable);
initConstraints(c, 0, 1, 2, 2, GridBagConstraints.BOTH, 2, 2, GridBagConstraints.CENTER, insets0);
layout.setConstraints(sp, c);
panel.add(sp);
libraryTable = buildJTable(libraryModel);
libraryTable.setEditingEnabled(false);
libraryTable.setBackground(LIGHT_SEPIA);
sp = new JScrollPane(libraryTable);
initConstraints(c, 3, 1, 2, 2, GridBagConstraints.BOTH, 2, 2, GridBagConstraints.CENTER, insets0);
layout.setConstraints(sp, c);
panel.add(sp);
selectedDefinitionNames = new NameSetPropertyEditor();
WBSNameSelectionModel wsm = new WBSNameSelectionModel(projectTable, selectedDefinitionNames);
projectTable.setSelectionModel(wsm);
WBSNameSelectionModel lsm = new WBSNameSelectionModel(libraryTable, selectedDefinitionNames);
libraryTable.setSelectionModel(lsm);
new SelectionListener(wsm, lsm, export);
addButton = new JButton(resources.getString("Overwrite"));
addButton.setIcon(export ? IconFactory.getRightArrowIcon() : IconFactory.getLeftArrowIcon());
addButton.setHorizontalTextPosition(export ? SwingConstants.LEFT : SwingConstants.RIGHT);
addButton.setMinimumSize(addButton.getPreferredSize());
addButton.setText(resources.getString("Add"));
addButton.setMnemonic('A');
addButton.setEnabled(false);
addButton.addActionListener(createActionListener("addDefinitionAction"));
initConstraints(c, 2, 1, 1, 1, GridBagConstraints.HORIZONTAL, 0, 1, GridBagConstraints.SOUTH, insets10);
layout.setConstraints(addButton, c);
panel.add(addButton);
addAllButton = new JButton(resources.getString("Add_All"));
addAllButton.setMnemonic('L');
addAllButton.setIcon(export ? IconFactory.getRightArrowIcon() : IconFactory.getLeftArrowIcon());
addAllButton.setHorizontalTextPosition(export ? SwingConstants.LEFT : SwingConstants.RIGHT);
addAllButton.addActionListener(createActionListener("addAllDefinitionsAction"));
initConstraints(c, 2, 2, 1, 1, GridBagConstraints.HORIZONTAL, 0, 1, GridBagConstraints.NORTH, insets10);
layout.setConstraints(addAllButton, c);
panel.add(addAllButton);
JLabel label = new JLabel(resources.format("Project_Heading_FMT", teamProject.getProjectName()));
initConstraints(c, 0, 0, 1, 1, GridBagConstraints.NONE, 0, 0, GridBagConstraints.WEST, insets0);
layout.setConstraints(label, c);
panel.add(label);
String libraryFileName = libraryFile.getFileName();
String header = (libraryFileName != null ? resources.format("Library_Heading_FMT", libraryFileName) : resources.getString("Org_Library_Heading"));
label = new JLabel(header);
initConstraints(c, 3, 0, 1, 1, GridBagConstraints.NONE, 0, 0, GridBagConstraints.WEST, insets0);
layout.setConstraints(label, c);
panel.add(label);
Box buttonPanel = Box.createHorizontalBox();
buttonPanel.add(Box.createHorizontalGlue());
okButton = new JButton(resources.getString(export ? "Export" : "Import"));
okButton.addActionListener(createActionListener("okAction"));
buttonPanel.add(okButton);
cancelButton = new JButton(resources.getString("Cancel"));
cancelButton.addActionListener(createActionListener("cancelAction"));
buttonPanel.add(Box.createHorizontalStrut(10));
buttonPanel.add(cancelButton);
initConstraints(c, 0, 3, 5, 1, GridBagConstraints.BOTH, 0, 0, GridBagConstraints.NORTH, new Insets(10, 0, 0, 0));
layout.setConstraints(buttonPanel, c);
panel.add(buttonPanel);
dialog.setContentPane(panel);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
cancelAction();
}
});
}
use of java.awt.event.WindowEvent in project dogecade by ebanisadr.
the class LoginScreen method openLoginWindow.
public static void openLoginWindow() {
//only run if you aren't already logged in
//TODO uncomment this when the server actually works as intended
//if (server.getUsername() != null) return;
//set up the basics of the JFrame and JPanel
JFrame frame = new JFrame("Login");
JPanel panel = new JPanel();
frame.add(panel);
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
//set up the components
JLabel usernameText = new JLabel("Username");
JTextField usernameBox = new JTextField(10);
JLabel badInfo = new JLabel("That username or password is invalid");
JLabel passwordText = new JLabel("Password");
JPasswordField passwordBox = new JPasswordField("", 10);
JButton loginButton = new JButton("Login");
//add everything to the panel
panel.add(usernameText);
panel.add(badInfo);
badInfo.setVisible(false);
panel.add(usernameBox);
panel.add(passwordText);
panel.add(passwordBox);
panel.add(loginButton);
//set up the action listeners
frame.getRootPane().setDefaultButton(loginButton);
loginButton.addActionListener(e -> {
final char[] password = passwordBox.getPassword();
if (Dogecade.server.login(usernameBox.getText(), password)) {
MainMenu.openMainMenu();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
Dogecade.logger.println("logged in");
} else {
badInfo.setVisible(true);
Dogecade.logger.println("failed to log in");
}
for (int i = 0; i < password.length; i++) password[i] = 0;
});
//make the window a little nicer, make it visible
frame.pack();
frame.setSize(frame.getWidth() + 100, frame.getHeight() + 100);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
use of java.awt.event.WindowEvent in project cayenne by apache.
the class CayenneModelerController method initBindings.
protected void initBindings() {
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
PROJECT_STATE_UTIL.saveLastState(projectController);
getApplication().getActionManager().getAction(ExitAction.class).exit();
}
});
// This is in Mac OSX only.
if (System.getProperty("os.name").startsWith("Mac OS")) {
Runnable runner = new Runnable() {
@Override
public void run() {
PROJECT_STATE_UTIL.saveLastState(projectController);
}
};
Runtime.getRuntime().addShutdownHook(new Thread(runner, "Window Prefs Hook"));
}
new DropTarget(frame, new DropTargetAdapter() {
@Override
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(dtde.getDropAction());
Transferable transferable = dtde.getTransferable();
dtde.dropComplete(processDropAction(transferable));
}
});
ComponentGeometry geometry = new ComponentGeometry(frame.getClass(), null);
geometry.bind(frame, 1200, 720, 0);
}
use of java.awt.event.WindowEvent in project cayenne by apache.
the class CayenneDialog method initCloseOnEscape.
/**
* Makes dialog closeable when ESC button is clicked.
*/
protected void initCloseOnEscape() {
// make dialog closable on escape
// TODO: Note that if a dialog contains subcomponents
// that use ESC for their own purposes (like editable JTable or JComboBox),
// this code will still close the dialog (e.g. not just an expanded
// ComboBox). To fix it see this advise (Swing is Fun!!):
//
// http://www.eos.dk/pipermail/swing/2001-June/000789.html
KeyStroke escReleased = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
ActionListener closeAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (CayenneDialog.this.isVisible()) {
// dispatch window closing event
WindowEvent windowClosing = new WindowEvent(CayenneDialog.this, WindowEvent.WINDOW_CLOSING);
CayenneDialog.super.processWindowEvent(windowClosing);
}
}
};
getRootPane().registerKeyboardAction(closeAction, escReleased, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
Aggregations