Example usage for java.awt.event WindowAdapter WindowAdapter

List of usage examples for java.awt.event WindowAdapter WindowAdapter

Introduction

In this page you can find the example usage for java.awt.event WindowAdapter WindowAdapter.

Prototype

WindowAdapter

Source Link

Usage

From source file:xdevs.lib.util.ScopeView.java

public ScopeView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    XYSeriesCollection dataSet = new XYSeriesCollection();
    serie = new XYSeries(yTitle);
    dataSet.addSeries(serie);//w ww  .  j  av a 2 s  .c  o m
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:xdevs.lib.util.ScopeMultiView.java

public ScopeMultiView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);/*from   w w w . j av a  2 s . co  m*/
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:StocksTable.java

public StocksTable() {
    super("Stocks Table");
    setSize(600, 300);//from w  w  w  .  j  a  va 2s . c  om

    m_data = new StockTableData();

    m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT);
    m_title.setFont(new Font("TimesRoman", Font.BOLD, 24));
    m_title.setForeground(Color.black);
    getContentPane().add(m_title, BorderLayout.NORTH);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);

    for (int k = 0; k < StockTableData.m_columns.length; k++) {
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment);
        TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(300, 100);//from  w  ww.j ava2s. c o  m

    UIManager.put("ProgressBar.selectionBackground", Color.black);
    UIManager.put("ProgressBar.selectionForeground", Color.white);
    UIManager.put("ProgressBar.foreground", new Color(8, 32, 128));

    progressBar = new JProgressBar();
    progressBar.setMinimum(minValue);
    progressBar.setMaximum(maxValue);
    progressBar.setStringPainted(true);

    JButton start = new JButton("Start");
    start.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Thread runner = new Thread() {
                public void run() {
                    counter = minValue;
                    while (counter <= maxValue) {
                        Runnable runme = new Runnable() {
                            public void run() {
                                progressBar.setValue(counter);
                            }
                        };
                        SwingUtilities.invokeLater(runme);
                        counter++;
                        try {
                            Thread.sleep(100);
                        } catch (Exception ex) {
                        }
                    }
                }
            };
            runner.start();
        }
    });

    getContentPane().add(progressBar, BorderLayout.CENTER);
    getContentPane().add(start, BorderLayout.WEST);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:Main.java

public ListRenderingFrame() {
    setTitle("ListRendering");
    setSize(400, 300);// www.  j a v  a 2  s.c  o  m
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Vector fonts = new Vector();
    fonts.add(new Font("Serif", Font.PLAIN, 8));
    fonts.add(new Font("SansSerif", Font.BOLD, 12));
    fonts.add(new Font("Monospaced", Font.PLAIN, 16));
    fonts.add(new Font("Dialog", Font.ITALIC, 12));
    fonts.add(new Font("DialogInput", Font.PLAIN, 12));
    JList fontList = new JList(fonts);
    fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fontList.setCellRenderer(new FontCellRenderer());
    JScrollPane scrollPane = new JScrollPane(fontList);

    JPanel p = new JPanel();
    p.add(scrollPane);
    fontList.addListSelectionListener(this);

    getContentPane().add(p, "Center");

    getContentPane().add(label, "South");
}

From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.ViewFrame.java

public ViewFrame(String title, final IView component) {
    super(title);
    if (component == null) {
        throw new IllegalArgumentException("component must not be NULL.");
    }//from  w  ww. j a v a 2 s  .c  om
    this.component = component;

    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            disposeView(component);
            helper.fireViewContainerClosed(ViewFrame.this);
        }
    });

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    final GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.weightx = 1.0d;
    cnstrs.weighty = 1.0d;
    cnstrs.fill = GridBagConstraints.BOTH;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridx = 0;
    cnstrs.gridy = 0;
    panel.add(component.getPanel(this), cnstrs);
    getContentPane().add(panel);
    pack();
}

From source file:com.mirth.connect.plugins.textviewer.TextViewer.java

@Override
public void viewAttachments(String channelId, Long messageId, String attachmentId) {
    // do viewing code
    Frame frame = new Frame("Text Viewer");
    frame.setLayout(new BorderLayout());

    try {//from  w w w.  j  av a2  s  . c o m
        Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId);
        byte[] content = Base64.decodeBase64(attachment.getContent());

        boolean isRTF = attachment.getType().toLowerCase().contains("rtf");
        //TODO set character encoding
        JEditorPane jEditorPane = new JEditorPane(isRTF ? "text/rtf" : "text/plain", new String(content));

        if (jEditorPane.getDocument().getLength() == 0) {
            // decoded when it should not have been.  i.e.) the attachment data was not encoded.
            jEditorPane.setText(new String(attachment.getContent()));
        }

        jEditorPane.setEditable(false);
        JScrollPane scrollPane = new javax.swing.JScrollPane();
        scrollPane.setViewportView(jEditorPane);
        frame.add(scrollPane);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
            }
        });

        frame.setSize(600, 800);

        Dimension dlgSize = frame.getSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            frame.setLocationRelativeTo(null);
        } else {
            frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        frame.setVisible(true);
    } catch (Exception e) {
        parent.alertThrowable(parent, e);
    }
}

From source file:edu.usf.cutr.fdot7.gui.SessionForm.java

/** Creates new form OSMSessionForm */
public SessionForm() {
    factory = new XmlBeanFactory(new FileSystemResource(
            System.getProperty("user.dir") + System.getProperty("file.separator") + "data-source.xml"));
    initComponents();/*from   www  .  ja va  2s .  com*/
    this.setLocationRelativeTo(null);
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            Test.mutex.release();
        }
    });
}

From source file:StocksTable2.java

public StocksTable2() {
    super("Stocks Table");
    setSize(600, 300);/*from   w  w  w.j  av a  2  s  . c o  m*/

    m_data = new StockTableData();

    m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT);
    m_title.setFont(new Font("TimesRoman", Font.BOLD, 24));
    m_title.setForeground(Color.black);
    getContentPane().add(m_title, BorderLayout.NORTH);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);

    for (int k = 0; k < StockTableData.m_columns.length; k++) {
        DefaultTableCellRenderer renderer = new ColoredTableCellRenderer();
        renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment);
        TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:JProgressBarDemo.java

public JProgressBarDemo() {
    super("JProgressBar Demo");
    setSize(300, 100);//from w  w  w  .  j a v a  2s . co  m

    UIManager.put("ProgressBar.selectionBackground", Color.black);
    UIManager.put("ProgressBar.selectionForeground", Color.white);
    UIManager.put("ProgressBar.foreground", new Color(8, 32, 128));

    progressBar = new JProgressBar();
    progressBar.setMinimum(minValue);
    progressBar.setMaximum(maxValue);
    progressBar.setStringPainted(true);

    JButton start = new JButton("Start");
    start.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Thread runner = new Thread() {
                public void run() {
                    counter = minValue;
                    while (counter <= maxValue) {
                        Runnable runme = new Runnable() {
                            public void run() {
                                progressBar.setValue(counter);
                            }
                        };
                        SwingUtilities.invokeLater(runme);
                        counter++;
                        try {
                            Thread.sleep(100);
                        } catch (Exception ex) {
                        }
                    }
                }
            };
            runner.start();
        }
    });

    getContentPane().add(progressBar, BorderLayout.CENTER);
    getContentPane().add(start, BorderLayout.WEST);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}