Search in sources :

Example 16 with WindowEvent

use of java.awt.event.WindowEvent in project gitblit by gitblit.

the class GitblitManager method initialize.

private void initialize() {
    setContentPane(getCenterPanel());
    setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
    setTitle("Gitblit Manager v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent event) {
            saveSizeAndPosition();
        }

        @Override
        public void windowOpened(WindowEvent event) {
            manageRegistrations();
        }
    });
    setSizeAndPosition();
    loadRegistrations();
    rebuildRecentMenu();
}
Also used : ImageIcon(javax.swing.ImageIcon) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 17 with WindowEvent

use of java.awt.event.WindowEvent in project zaproxy by zaproxy.

the class ManageAddOnsDialog method initialize.

/**
	 * This method initializes this
	 * 
	 */
private void initialize() {
    this.setTitle(Constant.messages.getString("cfu.manage.title"));
    //this.setContentPane(getJTabbed());
    this.setContentPane(getTopPanel());
    this.pack();
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(700, 500);
    }
    state = State.IDLE;
    // Handle escape key to close the dialog
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    AbstractAction escapeAction = new AbstractAction() {

        private static final long serialVersionUID = 3516424501887406165L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dispatchEvent(new WindowEvent(ManageAddOnsDialog.this, WindowEvent.WINDOW_CLOSING));
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
Also used : ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 18 with WindowEvent

use of java.awt.event.WindowEvent in project zaproxy by zaproxy.

the class ScanProgressDialog method initialize.

private void initialize() {
    this.setSize(new Dimension(580, 504));
    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel tab1 = new JPanel();
    tab1.setLayout(new GridBagLayout());
    JPanel hostPanel = new JPanel();
    hostPanel.setLayout(new GridBagLayout());
    hostPanel.add(new JLabel(Constant.messages.getString("ascan.progress.label.host")), LayoutHelper.getGBC(0, 0, 1, 0.4D));
    hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D));
    tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D));
    tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));
    JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
    buttonsPanel.add(getCopyToClipboardButton());
    buttonsPanel.add(getCloseButton());
    tab1.add(buttonsPanel, LayoutHelper.getGBC(0, 2, 3, 1.0D));
    tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.progress"), null, tab1, null, 0);
    this.add(tabbedPane);
    int mins = extension.getScannerParam().getMaxChartTimeInMins();
    if (mins > 0) {
        // Treat zero mins as disabled
        JPanel tab2 = new JPanel();
        tab2.setLayout(new GridBagLayout());
        // Name not shown, so no need to i18n
        this.seriesTotal = new TimeSeries("TotalResponses");
        final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal);
        this.series100 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.1xx"));
        this.series200 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.2xx"));
        this.series300 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.3xx"));
        this.series400 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.4xx"));
        this.series500 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.5xx"));
        long maxAge = mins * 60;
        this.seriesTotal.setMaximumItemAge(maxAge);
        this.series100.setMaximumItemAge(maxAge);
        this.series200.setMaximumItemAge(maxAge);
        this.series300.setMaximumItemAge(maxAge);
        this.series400.setMaximumItemAge(maxAge);
        this.series500.setMaximumItemAge(maxAge);
        dataset.addSeries(series100);
        dataset.addSeries(series200);
        dataset.addSeries(series300);
        dataset.addSeries(series400);
        dataset.addSeries(series500);
        chart = createChart(dataset);
        // Set up some vaguesly sensible colours
        // Totals
        chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK);
        // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GRAY);
        // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN);
        // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE);
        // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.MAGENTA);
        // 500: Internal error
        chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED);
        final ChartPanel chartPanel = new ChartPanel(chart);
        tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D));
        tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.chart"), null, tab2, null, 1);
    }
    // Stop the updating thread when the window is closed
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            stopThread = true;
        }
    });
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) TimeSeries(org.jfree.data.time.TimeSeries) ChartPanel(org.jfree.chart.ChartPanel) GridBagLayout(java.awt.GridBagLayout) JTabbedPane(javax.swing.JTabbedPane) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Point(java.awt.Point) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) WindowEvent(java.awt.event.WindowEvent)

Example 19 with WindowEvent

use of java.awt.event.WindowEvent in project zaproxy by zaproxy.

the class AbstractDialog method initialize.

/**
	 * This method initializes this
	 */
private void initialize() {
    this.setVisible(false);
    this.setIconImages(DisplayUtils.getZapIconImages());
    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(300, 200);
    }
    this.setTitle(Constant.PROGRAM_NAME);
    //  Handle escape key to close the dialog    
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    AbstractAction escapeAction = new AbstractAction() {

        private static final long serialVersionUID = 3516424501887406165L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dispatchEvent(new WindowEvent(AbstractDialog.this, WindowEvent.WINDOW_CLOSING));
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
Also used : ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 20 with WindowEvent

use of java.awt.event.WindowEvent in project L42 by ElvisResearchGroup.

the class Frame method createNew.

private static Frame createNew(String wName, String html, int x, int y) {
    FutureTask<Frame> future = new FutureTask<>(() -> {
        final Frame frame = new Frame(Frame.extractTitle(html));
        JFXPanel jfxPanel = new JFXPanel();
        frame.createHtmlContent(jfxPanel, html);
        frame.getContentPane().add(jfxPanel);
        frame.setMinimumSize(new Dimension(x, y));
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                Frame.close(wName);
            }
        });
        frame.setVisible(true);
        return frame;
    });
    SwingUtilities.invokeLater(future);
    try {
        return future.get();
    } catch (ExecutionException e) {
        throw propagateException(e.getCause());
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
}
Also used : JFrame(javax.swing.JFrame) JFXPanel(javafx.embed.swing.JFXPanel) FutureTask(java.util.concurrent.FutureTask) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

WindowEvent (java.awt.event.WindowEvent)184 WindowAdapter (java.awt.event.WindowAdapter)128 JPanel (javax.swing.JPanel)41 JButton (javax.swing.JButton)38 BorderLayout (java.awt.BorderLayout)35 JFrame (javax.swing.JFrame)35 Dimension (java.awt.Dimension)31 ActionEvent (java.awt.event.ActionEvent)31 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)25 ActionListener (java.awt.event.ActionListener)23 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)17 Insets (java.awt.Insets)14 Frame (java.awt.Frame)12 JTextArea (javax.swing.JTextArea)12 Container (java.awt.Container)11 JDialog (javax.swing.JDialog)11 IOException (java.io.IOException)9