Search in sources :

Example 56 with WindowAdapter

use of java.awt.event.WindowAdapter in project processdash by dtuma.

the class TimeLogEditor method constructUserInterface.

/*
     * methods for constructing the user interface
     */
private void constructUserInterface() {
    loadCustomDimensions();
    frame = new JFrame(getResource("Time_Log_Editor_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, "UsingTimeLogEditor");
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, constructTreePanel(), constructEditPanel());
    splitPane.setDividerLocation(dividerLocation);
    // Setup drag-and-drop support on Java 6 and above
    new FallbackObjectFactory<TimeLogEditorDragDropSetup>(TimeLogEditorDragDropSetup.class).add(//
    "TimeLogEditorDragDropSetupJava6").get(true).setupEditorForDragDrop(this);
    Container panel = frame.getContentPane();
    panel.setLayout(new BorderLayout());
    panel.add(BorderLayout.NORTH, constructFilterPanel());
    panel.add(BorderLayout.CENTER, splitPane);
    panel.add(BorderLayout.SOUTH, constructControlPanel());
    createRecalcTimer();
}
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 57 with WindowAdapter

use of java.awt.event.WindowAdapter in project sling by apache.

the class RequestAnalyzerWebConsole method showWindow.

private synchronized void showWindow() throws ServletException, IOException {
    if (this.frame == null) {
        final File toAnalyze = this.getLogFileCopy();
        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        MainFrame frame = new MainFrame(toAnalyze, Integer.MAX_VALUE, screenSize);
        // exit the application if the main frame is closed
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // remove the tmp file we showed
                if (toAnalyze.exists()) {
                    toAnalyze.delete();
                }
                // clear the window reference
                RequestAnalyzerWebConsole.this.frame = null;
            }
        });
        this.frame = frame;
    }
    // make sure the window is visible, try to bring to the front
    this.frame.setVisible(true);
    this.frame.toFront();
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) File(java.io.File) MainFrame(org.apache.sling.reqanalyzer.impl.gui.MainFrame)

Example 58 with WindowAdapter

use of java.awt.event.WindowAdapter in project sling by apache.

the class Main method main.

public static void main(String[] args) throws IOException {
    if (GraphicsEnvironment.isHeadless()) {
        System.err.println("Cannot run in headless mode");
        System.exit(1);
    }
    if (args.length == 0) {
        System.err.println("Missing argument <file>");
        System.exit(1);
    }
    File file = new File(args[0]);
    if (!file.canRead()) {
        System.err.println("Cannot read from file " + file);
        System.exit(1);
    }
    final int limit;
    if (args.length >= 2) {
        limit = Integer.parseInt(args[1]);
    } else {
        limit = Integer.MAX_VALUE;
    }
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    MainFrame frame = new MainFrame(file, limit, screenSize);
    frame.setVisible(true);
    // exit the application if the main frame is closed
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) File(java.io.File)

Example 59 with WindowAdapter

use of java.awt.event.WindowAdapter in project sling by apache.

the class RequestListSelectionListener method valueChanged.

public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
        int idx = lsm.getMinSelectionIndex();
        if (idx >= 0) {
            try {
                idx = table.getRowSorter().convertRowIndexToModel(idx);
                TableModel tm = ((RequestTrackerFile) table.getModel()).getData(idx);
                if (dataField == null) {
                    dataField = new JTable();
                    dataField.setAutoCreateRowSorter(true);
                    dataField.setGridColor(Color.GRAY);
                    dataField.setShowGrid(true);
                    dataField.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    dataField.setRowSelectionAllowed(true);
                    dataField.setTableHeader(new JTableHeader(dataField.getColumnModel()));
                    dataField.setFont(new Font("Monospaced", dataField.getFont().getStyle(), dataField.getFont().getSize()));
                    dataField.setShowHorizontalLines(false);
                    //                        dataField.setIntercellSpacing(new Dimension(3, 5));
                    JDialog d = new JDialog(this.parent);
                    d.add(new JScrollPane(dataField));
                    d.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            dataField = null;
                        }
                    });
                    // setup location and size and ensure updating preferences
                    Util.setupComponentLocationSize(d, REQUEST_X, REQUEST_Y, REQUEST_WIDTH, REQUEST_HEIGHT, (int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 4, (int) screenSize.getWidth() / 2, (int) screenSize.getHeight() / 2);
                    d.setVisible(true);
                }
                dataField.setModel(tm);
                Util.setupColumnWidths(dataField.getColumnModel(), REQUEST_COLS);
            } catch (IOException e1) {
            // ignore
            }
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ListSelectionModel(javax.swing.ListSelectionModel) JTableHeader(javax.swing.table.JTableHeader) WindowAdapter(java.awt.event.WindowAdapter) IOException(java.io.IOException) Font(java.awt.Font) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel) JDialog(javax.swing.JDialog)

Example 60 with WindowAdapter

use of java.awt.event.WindowAdapter in project cloudstack by apache.

the class VncClient method createVncClientMainWindow.

private Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title) {
    // Create AWT windows
    final Frame frame = new Frame(title + " - VNCle");
    // Use scrolling pane to support screens, which are larger than ours
    ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    scroller.add(canvas);
    scroller.setSize(screen.getFramebufferWidth(), screen.getFramebufferHeight());
    frame.add(scroller);
    frame.pack();
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            frame.setVisible(false);
            shutdown();
        }
    });
    return frame;
}
Also used : Frame(java.awt.Frame) ScrollPane(java.awt.ScrollPane) WindowEvent(java.awt.event.WindowEvent) 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