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:FontDialog.java

public FontDialog() {
    setTitle("FontDialog");
    setSize(600, 200);/*from   ww  w.  j a v a 2s. c o  m*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Container contentPane = getContentPane();
    GridBagLayout gbl = new GridBagLayout();
    contentPane.setLayout(gbl);

    style.setSelectedIndex(0);

    JLabel label = new JLabel("Size: ");

    sample.setEditable(false);

    getContentPane().add(new JScrollPane(style));
    getContentPane().add(bold);
    getContentPane().add(italic);
    getContentPane().add(label);
    getContentPane().add(size);
    getContentPane().add(sample);
    sample.setText("The quick brown fox");

    bold.addActionListener(this);
    italic.addActionListener(this);
    style.addListSelectionListener(this);
    size.addActionListener(this);
}

From source file:TextAreaFrame.java

public TextAreaFrame() {
    JPanel p = new JPanel();

    p.add(insertButton);/*from w w w  . j a  v  a 2 s.c o  m*/
    insertButton.addActionListener(this);

    p.add(wrapButton);
    wrapButton.addActionListener(this);

    p.add(noWrapButton);
    noWrapButton.addActionListener(this);

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

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

    setTitle("TextAreaTest");
    setSize(300, 300);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:app.gui.ViewGraphic.java

public ViewGraphic(String title) {
    setSize(600, 400);/* w w w.ja va2  s .  co m*/
    setLocationRelativeTo(this);
    setTitle(title);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            dispose();
        }
    });
    setLayout(new BorderLayout());

    serieError = new XYSeries(title);

    dataset = new XYSeriesCollection();
    dataset.addSeries(serieError);

    chart = ChartFactory.createXYLineChart(title, Translate.get("GUI_PERIODS"), Translate.get("GUI_ERROR"),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    add(new ChartPanel(chart), BorderLayout.CENTER);

    JPanel south = new JPanel(new MigLayout());

    lblError = new JLabel("");
    lblError.setHorizontalTextPosition(SwingConstants.LEFT);
    lblError.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblErrorTitle = new JLabel(Translate.get("GUI_ERROR") + ": ");
    lblErrorTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblErrorTitle);
    south.add(lblError, "wrap");

    add(south, BorderLayout.SOUTH);
    setVisible(true);
}

From source file:SplitSample.java

public SplitSample() {
    super("Simple Split Pane");
    setSize(400, 400);/*from ww  w .  java2 s . c  om*/
    getContentPane().setLayout(new BorderLayout());

    JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel());
    spLeft.setDividerSize(8);
    spLeft.setContinuousLayout(true);

    JSplitPane spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel());
    spRight.setDividerSize(8);
    spRight.setContinuousLayout(true);

    split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, spLeft, spRight);
    split.setContinuousLayout(false);
    split.setOneTouchExpandable(true);

    getContentPane().add(split, BorderLayout.CENTER);

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

    setVisible(true);
}

From source file:MessageDigestTest.java

public MessageDigestFrame() {
    setTitle("MessageDigestTest");
    setSize(400, 200);/*from   w w w.java  2  s  . com*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    JPanel panel = new JPanel();
    ButtonGroup group = new ButtonGroup();
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JCheckBox b = (JCheckBox) event.getSource();
            setAlgorithm(b.getText());
        }
    };
    addCheckBox(panel, "SHA-1", group, true, listener);
    addCheckBox(panel, "MD5", group, false, listener);

    Container contentPane = getContentPane();

    contentPane.add(panel, "North");
    contentPane.add(new JScrollPane(message), "Center");
    contentPane.add(digest, "South");
    digest.setFont(new Font("Monospaced", Font.PLAIN, 12));

    setAlgorithm("SHA-1");

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem fileDigestItem = new JMenuItem("File digest");
    fileDigestItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            loadFile();
        }
    });
    menu.add(fileDigestItem);
    JMenuItem textDigestItem = new JMenuItem("Text area digest");
    textDigestItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String m = message.getText();
            computeDigest(m.getBytes());
        }
    });
    menu.add(textDigestItem);
    menuBar.add(menu);
    setJMenuBar(menuBar);
}

From source file:BorderTest.java

public BorderTest() {
    JPanel p = new JPanel();
    Border[] border = new Border[] { BorderFactory.createEtchedBorder(),
            BorderFactory.createTitledBorder("Border types"), BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createEtchedBorder(),
            BorderFactory.createLineBorder(Color.blue),
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.blue), BorderFactory.createEmptyBorder()

    };/*  w w  w  .  j  av a2  s. c  o  m*/
    p.setLayout(new GridLayout(border.length, 0, 3, 3));

    for (int i = 0; i < border.length; i++) {
        JPanel borderPanel = new JPanel();
        borderPanel.setBorder(border[i]);
        p.add(borderPanel);
    }
    getContentPane().add(p, "Center");
    setTitle("BorderTest");
    setSize(600, 400);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:Main.java

public Main() {
    super("Swing List with Tab Renenderer");
    setSize(500, 240);//  w  w  w  .j av  a2  s .c o m

    String[] items = { "cloumn 1\t column  2\t Column 3", "cloumn 1\t column  2\t Column 3" };

    list = new JList(items);

    TabListCellRenderer renderer = new TabListCellRenderer();
    list.setCellRenderer(renderer);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(list);
    getContentPane().add(scrollPane, BorderLayout.CENTER);

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

    setVisible(true);
}

From source file:TabRenendererList.java

public TabRenendererList() {
    super("Swing List with Tab Renenderer");
    setSize(500, 240);/*  ww w  . j  ava  2s .c  o  m*/

    String[] items = { "cloumn 1\t column  2\t Column 3", "cloumn 1\t column  2\t Column 3" };

    list = new JList(items);

    TabListCellRenderer renderer = new TabListCellRenderer();
    list.setCellRenderer(renderer);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(list);
    getContentPane().add(scrollPane, BorderLayout.CENTER);

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

    setVisible(true);
}

From source file:SimpleInternalFrameDemo.java

public SimpleInternalFrameDemo() {
    super("Internal Frame Demo");
    setSize(500, 400);//w w  w. java 2 s .  com
    openButton = new JButton("Open");
    macButton = new JButton("Mac");
    javaButton = new JButton("Metal");
    motifButton = new JButton("Motif");
    winButton = new JButton("Windows");
    Panel p = new Panel();
    p.add(openButton);
    p.add(macButton);
    p.add(javaButton);
    p.add(motifButton);
    p.add(winButton);
    add(p, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    openButton.addActionListener(new OpenListener());
    LnFListener lnf = new LnFListener(this);
    macButton.addActionListener(lnf);
    javaButton.addActionListener(lnf);
    motifButton.addActionListener(lnf);
    winButton.addActionListener(lnf);

    // Set up the layered pane
    desktop = new JDesktopPane();
    desktop.setOpaque(true);
    add(desktop, BorderLayout.CENTER);
}

From source file:Ellipse.java

public Ellipse() {
    super();//  w  w w.  j a v a  2s . co  m
    Container container = getContentPane();

    canvas = new DrawingCanvas();
    container.add(canvas);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 2));
    panel.add(new JLabel("x,y: ", JLabel.RIGHT));
    location = new JLabel("");
    panel.add(location);

    container.add(panel, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    setSize(600, 300);
    setVisible(true);
}