Search in sources :

Example 66 with WindowAdapter

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);
    }
}
Also used : ZooInspectorManagerImpl(org.apache.zookeeper.inspector.manager.ZooInspectorManagerImpl) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) IconResource(org.apache.zookeeper.inspector.gui.IconResource) WindowAdapter(java.awt.event.WindowAdapter) ZooInspectorPanel(org.apache.zookeeper.inspector.gui.ZooInspectorPanel)

Example 67 with WindowAdapter

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);
}
Also used : Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane)

Example 68 with WindowAdapter

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();
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Box(javax.swing.Box) WindowEvent(java.awt.event.WindowEvent) EmptyBorder(javax.swing.border.EmptyBorder) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 69 with WindowAdapter

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);
}
Also used : DropTargetAdapter(java.awt.dnd.DropTargetAdapter) ComponentGeometry(org.apache.cayenne.modeler.pref.ComponentGeometry) WindowEvent(java.awt.event.WindowEvent) Transferable(java.awt.datatransfer.Transferable) WindowAdapter(java.awt.event.WindowAdapter) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent)

Example 70 with WindowAdapter

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();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JEditorPane(javax.swing.JEditorPane) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter)

Aggregations

WindowAdapter (java.awt.event.WindowAdapter)143 WindowEvent (java.awt.event.WindowEvent)140 JPanel (javax.swing.JPanel)40 JButton (javax.swing.JButton)36 JFrame (javax.swing.JFrame)34 BorderLayout (java.awt.BorderLayout)32 Dimension (java.awt.Dimension)30 JLabel (javax.swing.JLabel)26 JScrollPane (javax.swing.JScrollPane)25 ActionEvent (java.awt.event.ActionEvent)22 ActionListener (java.awt.event.ActionListener)20 FlowLayout (java.awt.FlowLayout)18 GridBagConstraints (java.awt.GridBagConstraints)18 GridBagLayout (java.awt.GridBagLayout)18 Insets (java.awt.Insets)14 Frame (java.awt.Frame)13 Container (java.awt.Container)12 JTextArea (javax.swing.JTextArea)12 JDialog (javax.swing.JDialog)11 IOException (java.io.IOException)9