use of java.awt.event.WindowAdapter in project zookeeper by apache.
the class ZooInspector method main.
/**
* @param args
* - not used. The value of these parameters will have no effect
* on the application
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame frame = new JFrame("ZooInspector");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
iconResource = new IconResource();
final ZooInspectorPanel zooInspectorPanel = new ZooInspectorPanel(new ZooInspectorManagerImpl(), iconResource);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
super.windowClosed(e);
zooInspectorPanel.disconnect(true);
}
});
frame.setContentPane(zooInspectorPanel);
frame.setSize(1024, 768);
frame.setVisible(true);
} catch (Exception e) {
LoggerFactory.getLogger().error("Error occurred loading ZooInspector", e);
JOptionPane.showMessageDialog(null, "ZooInspector failed to start: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
use of java.awt.event.WindowAdapter 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.WindowAdapter 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.WindowAdapter 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.WindowAdapter in project cayenne by apache.
the class ErrorDebugDialog method init.
protected void init() {
setResizable(false);
Container pane = this.getContentPane();
pane.setLayout(new BorderLayout());
// info area
JEditorPane infoText = new JEditorPane("text/html", infoHTML());
infoText.setBackground(pane.getBackground());
infoText.setEditable(false);
// popup hyperlinks
infoText.addHyperlinkListener(this);
JPanel infoPanel = new JPanel();
infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
infoPanel.add(infoText);
pane.add(infoPanel, BorderLayout.NORTH);
// exception area
if (throwable != null) {
exText.setEditable(false);
exText.setLineWrap(true);
exText.setWrapStyleWord(true);
exText.setRows(16);
exText.setColumns(40);
JScrollPane exScroll = new JScrollPane(exText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
exPanel = new JPanel();
exPanel.setLayout(new BorderLayout());
exPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
exPanel.add(exScroll, BorderLayout.CENTER);
// buttons
showHide = new JButton("");
showHide.addActionListener(this);
if (isDetailed()) {
showDetails();
} else {
hideDetails();
}
}
close = new JButton("Close");
close.addActionListener(this);
JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close } : new JButton[] { close };
pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH);
// add a listener to clear static variables, not to produce garbage
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
instance = null;
}
});
// prepare to display
this.pack();
this.centerWindow();
}
Aggregations