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:org.altusmetrum.telegps.TeleGPSGraphUI.java

TeleGPSGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
    super(file.getName());
    state = null;/* ww  w .  j a  v  a 2 s .  c  o m*/

    pane = new JTabbedPane();

    enable = new AltosUIEnable();
    stats = new AltosFlightStats(states);
    graphDataSet = new AltosGraphDataSet(states);
    graph = new AltosGraph(enable, stats, graphDataSet);
    statsTable = new AltosFlightStatsTable(stats);

    map = new AltosUIMap();

    pane.add("Graph", graph.panel);
    pane.add("Configure Graph", enable);
    pane.add("Statistics", statsTable);
    fill_map(states);
    pane.add("Map", map);

    setContentPane(pane);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    pack();

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    TeleGPS.add_window();

    setVisible(true);

    if (state != null)
        map.centre(state);

}

From source file:gui.FormFrame.java

FormFrame(MainHandler mainHandler, final String usage, Pays argpays) throws PaysNotFoundException {
    this.setResizable(false);

    this.usage = usage;
    this.argpays = argpays;
    mainPanel = new JPanel();
    formPanel = new JPanel();
    this.mainHandler = mainHandler;
    //this.setLayout(new FlowLayout());
    this.getContentPane().add(mainPanel);
    init();/*from  w  w w .  ja v  a  2s  .  c o m*/
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();
        }

        public void close() {
            int dialButton = JOptionPane.OK_CANCEL_OPTION;
            int dialResult;
            dialResult = JOptionPane.showConfirmDialog(null,
                    "Vous etes sur le point de quitter sans avoir" + usage, "Attention !", dialButton);
            if (dialResult == JOptionPane.YES_OPTION) {
                dispose();
            }
        }
    });
}

From source file:AlphaCompositeDemo.java

public AlphaCompositeDemo() {
    super();//from   www.  j av  a 2s .  c  o m
    Container container = getContentPane();

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

    rulesBox = new JComboBox(rulesLabels);
    rulesBox.setSelectedIndex(0);
    rulesBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    rulesBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            canvas.compositeRule = rules[cb.getSelectedIndex()];
            canvas.repaint();
        }
    });

    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(25);
    slider.setMinorTickSpacing(25);
    slider.setPaintLabels(true);
    slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider slider = (JSlider) e.getSource();
            canvas.alphaValue = (float) slider.getValue() / 100;
            canvas.repaint();
        }
    });

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 3));
    panel.add(rulesBox);
    panel.add(new JLabel("Alpha Adjustment x E-2: ", JLabel.RIGHT));
    panel.add(slider);
    container.add(panel, BorderLayout.SOUTH);

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

From source file:com.haulmont.cuba.desktop.LoginDialog.java

public LoginDialog(JFrame owner, Connection connection) {
    super(owner);
    this.connection = connection;
    this.loginProperties = new LoginProperties();
    Configuration configuration = AppBeans.get(Configuration.NAME);
    desktopConfig = configuration.getConfig(DesktopConfig.class);
    this.locales = configuration.getConfig(GlobalConfig.class).getAvailableLocales();
    resolvedLocale = resolveLocale();/*from   ww w.  jav  a2  s.com*/
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            DesktopComponentsHelper.getTopLevelFrame(LoginDialog.this).activate();
        }
    });
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setTitle(messages.getMainMessage("loginWindow.caption", resolvedLocale));
    setContentPane(createContentPane());
    setResizable(false);
    pack();
}

From source file:TableSortDemo.java

public TableSortDemo() {
    super();//w ww . j a v a 2  s .  com
    setSize(600, 300);

    tableModel = new MyTableModel();

    getContentPane().add(titleLabel, BorderLayout.NORTH);
    table.setModel(tableModel);

    JTableHeader header = table.getTableHeader();
    header.setUpdateTableInRealTime(true);
    header.addMouseListener(tableModel.new ColumnListener(table));
    header.setReorderingAllowed(true);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(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:RSAccounts.java

public static void main(String[] args) {
    RSAccounts accounts = new RSAccounts();

    accounts.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//w w w . jav a2  s  .c o  m
        }
    });

    accounts.init();
    accounts.buildGUI();
}

From source file:de.huxhorn.lilith.swing.AboutDialog.java

public AboutDialog(Frame owner, String title, String appName) {
    super(owner, title, false);
    wasScrolling = true;//w  ww .j a  va 2s.  c  o  m
    setLayout(new BorderLayout());
    InputStream is = MainFrame.class.getResourceAsStream("/about/aboutText.txt");
    String aboutText = null;
    final Logger logger = LoggerFactory.getLogger(AboutDialog.class);
    if (is != null) {
        try {
            aboutText = IOUtils.toString(is, StandardCharsets.UTF_8);
        } catch (IOException e) {
            if (logger.isErrorEnabled())
                logger.error("Exception while loading aboutText!! *grrr*");
        }
    }
    try {
        aboutPanel = new AboutPanel(MainFrame.class.getResource("/about/lilith_big.jpg"),
                new Rectangle(50, 50, 400, 200), aboutText, MainFrame.class.getResource("/about/lilith.jpg"),
                appName, 20);
        //aboutPanel.setDebug(true);
        add(aboutPanel, BorderLayout.CENTER);
    } catch (IOException e) {
        if (logger.isErrorEnabled())
            logger.error("Exception creating about panel!!");
    }
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        /**
         * Invoked when a window is in the process of being closed.
         * The close operation can be overridden at this point.
         */
        @Override
        public void windowClosing(WindowEvent e) {
            setVisible(false);
        }
    });

}

From source file:Charts2D.java

public Charts2D() {
    super("2D Charts");
    setSize(720, 280);//from  w  w w . j  a  va 2s . c o  m
    getContentPane().setLayout(new GridLayout(1, 3, 10, 0));
    getContentPane().setBackground(Color.white);

    int[] xData = new int[8];
    int[] yData = new int[8];
    for (int i = 0; i < xData.length; i++) {
        xData[i] = i;
        yData[i] = (int) (Math.random() * 100);
        if (i > 0)
            yData[i] = (yData[i - 1] + yData[i]) / 2;
    }

    JChart2D chart = new JChart2D(JChart2D.LineChart, xData.length, xData, yData, "Line Chart");
    chart.setStroke(new BasicStroke(5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
    chart.setLineColor(new Color(0, 28, 28));
    getContentPane().add(chart);

    chart = new JChart2D(JChart2D.ColumnChart, xData.length, xData, yData, "Column Chart");
    GradientPaint gp = new GradientPaint(0, 100, Color.white, 0, 300, Color.blue, true);
    chart.setGradient(gp);
    chart.setEffectIndex(JChart2D.Gradientffect);
    chart.setDrawShadow(true);
    getContentPane().add(chart);

    chart = new JChart2D(JChart2D.PieChart, xData.length, xData, yData, "Pie Chart");
    ImageIcon icon = new ImageIcon("largeJava2slogo.GIF");
    chart.setForegroundImage(icon.getImage());
    chart.setEffectIndex(JChart2D.ImageEffect);
    chart.setDrawShadow(true);
    getContentPane().add(chart);

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

    setVisible(true);
}

From source file:com.lcdfx.pipoint.PiPoint.java

public PiPoint(String[] args) {

    this.addWindowListener(new WindowAdapter() {
        @Override//from  w w  w  . j a v  a 2  s .  c om
        public void windowClosing(WindowEvent ev) {
            shutDown();
        }
    });

    // add logging
    logger = Logger.getLogger(this.getClass().getName());
    logger.log(Level.INFO,
            "PiPoint version " + PiPoint.class.getPackage().getImplementationVersion() + " running under "
                    + System.getProperty("java.vm.name") + " v" + System.getProperty("java.vm.version"));

    // get command line options
    CommandLineParser parser = new BasicParser();
    Map<String, String> cmdOptions = new HashMap<String, String>();
    Options options = new Options();
    options.addOption(new Option("f", "fullscreen", false, "fullscreen mode (no cursor)"));
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
        for (Option option : cmd.getOptions()) {
            cmdOptions.put(option.getOpt(), option.getValue());
        }
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar pipoint.jar", options);
        System.exit(0);
    }

    if (cmd.hasOption("f")) {
        setUndecorated(true);
        BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
        Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0),
                "blank cursor");
        getContentPane().setCursor(blankCursor);
    }

    // instantiate the RendererManager
    mgr = new DlnaRendererManager(this);
    mgr.refreshDevices();

    nowPlayingPanel = new NowPlayingPanel(this);
    mgr.getRenderer().addListener(nowPlayingPanel);
    devicePanel = new DevicePanel(this);

    this.getContentPane().setPreferredSize(new Dimension(DISPLAY_WIDTH, DISPLAY_HEIGHT));
    this.getContentPane().add(devicePanel);
}

From source file:DialogSeparator.java

public FlightReservation() {
    super("Dialog ");

    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    c.add(new DialogSeparator("Options"));

    ButtonGroup group = new ButtonGroup();
    JRadioButton r1 = new JRadioButton("First class");
    group.add(r1);//from  w ww  .  java  2s. c o  m
    c.add(r1);

    JRadioButton r2 = new JRadioButton("Business");
    group.add(r2);
    c.add(r2);

    JRadioButton r3 = new JRadioButton("Coach");
    group.add(r3);
    c.add(r3);

    c.add(new DialogSeparator());

    JButton b3 = new JButton("Exit");
    c.add(b3);

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

    setSize(300, 200);
    setVisible(true);
}