List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:edu.uchc.octane.OctanePlugin.java
/** * Opens the Octane window/*ww w . j a va 2s. c om*/ * @param dataset The dataset */ void openWindow(TrajDataset dataset) { ctl_.setup(dataset); dict_.put(imp_, this); // keep the reference to the plugin alive imp_.getWindow().addWindowListener(new WindowAdapter() { boolean wasVisible; @Override public void windowIconified(WindowEvent e) { wasVisible = ctl_.getWindow().isVisible(); ctl_.getWindow().setVisible(false); } @Override public void windowDeiconified(WindowEvent e) { ctl_.getWindow().setVisible(wasVisible); } @Override public void windowClosed(WindowEvent e) { ctl_.getWindow().dispose(); dict_.remove(imp_); } }); }
From source file:StocksTable5.java
public StocksTable5() { 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(true); header.addMouseListener(m_data.new ColumnListener(m_table)); header.setReorderingAllowed(true); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.mirth.connect.plugins.imageviewer.ImageViewer.java
public void viewAttachments(String channelId, Long messageId, String attachmentId) { JFrame frame = new JFrame("Image Viewer"); try {/*from ww w . ja va 2s. c om*/ Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId); byte[] rawData = attachment.getContent(); ByteArrayInputStream bis = new ByteArrayInputStream(rawData); image = ImageIO.read(new Base64InputStream(bis)); JScrollPane pictureScrollPane = new JScrollPane(new JLabel(new ImageIcon(image))); pictureScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pictureScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); frame.add(pictureScrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.pack(); int imageWidth = image.getWidth(); int imageHeight = image.getHeight(); // Resize the frame so that it fits and scrolls images larger than // 800x600 properly. if (imageWidth > 800 || imageHeight > 600) { int width = imageWidth; int height = imageHeight; if (imageWidth > 800) { width = 800; } if (imageHeight > 600) { height = 600; } // Also add the scrollbars to the window width if necessary. Integer scrollBarWidth = (Integer) UIManager.get("ScrollBar.width"); int verticalScrollBar = 0; int horizontalScrollBar = 0; if (width == 800) { horizontalScrollBar = scrollBarWidth.intValue(); } if (height == 600) { verticalScrollBar = scrollBarWidth.intValue(); } // Also add the window borders to the width. width = width + frame.getInsets().left + frame.getInsets().right + verticalScrollBar; height = height + frame.getInsets().top + frame.getInsets().bottom + horizontalScrollBar; frame.setSize(width, height); } 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:AffineTransformApp.java
public AffineTransformApp() { super();//from w w w . j a v a2s . co m Container container = getContentPane(); displayPanel = new DisplayPanel(); container.add(displayPanel); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 4, 5, 5)); scaleXval = new JComboBox(scaleValues); scaleXval.setSelectedItem("1.00"); scaleXval.addActionListener(new ComboBoxListener()); scaleYval = new JComboBox(scaleValues); scaleYval.setSelectedItem("1.00"); scaleYval.addActionListener(new ComboBoxListener()); shearXval = new JComboBox(shearValues); shearXval.setSelectedItem("0.00"); shearXval.addActionListener(new ComboBoxListener()); shearYval = new JComboBox(shearValues); shearYval.setSelectedItem("0.00"); shearYval.addActionListener(new ComboBoxListener()); panel.add(new JLabel("Scale X value:")); panel.add(scaleXval); panel.add(new JLabel("Scale Y value:")); panel.add(scaleYval); panel.add(new JLabel("Shear X value:")); panel.add(shearXval); panel.add(new JLabel("Shear Y value:")); panel.add(shearYval); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10); setVisible(true); }
From source file:com.mirth.connect.client.ui.editors.JavaScriptEditorDialog.java
private void initialize(String script) { this.parent = PlatformUI.MIRTH_FRAME; initComponents();/*from w w w .jav a2 s . co m*/ scriptContent.setSaveEnabled(false); setSavedScript(script); scriptContent.setCaretPosition(0); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cancelButtonActionPerformed(null); } }); pack(); new DropTarget(scriptContent, this); Dimension dlgSize = getPreferredSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { setLocationRelativeTo(null); } else { setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } setVisible(true); }
From source file:CombineApp.java
public CombineApp() { super("TBandCombineOp"); Container container = getContentPane(); displayPanel = new CombinePanel(); container.add(displayPanel);/*from ww w . j a va 2 s.co m*/ JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 2)); panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset...")); redBandButton = new JButton("Show Red Band"); redBandButton.addActionListener(new ButtonListener()); greenBandButton = new JButton("Show Green Band"); greenBandButton.addActionListener(new ButtonListener()); blueBandButton = new JButton("Show Blue Band"); blueBandButton.addActionListener(new ButtonListener()); inverseBandButton = new JButton("Invert All Bands"); inverseBandButton.addActionListener(new ButtonListener()); middleBandButton = new JButton("Average Each Band"); middleBandButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(redBandButton); panel.add(blueBandButton); panel.add(greenBandButton); panel.add(inverseBandButton); panel.add(middleBandButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(displayPanel.getWidth(), displayPanel.getHeight()); setVisible(true); }
From source file:ColorTableColumnRenderer.java
public ColorTableColumnRenderer() { super("Stocks Table"); setSize(300, 300);// w w w . j a va2 s .co m tableModel = new MyTableModel(); table = new JTable(); table.setModel(tableModel); DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); TableColumn column = new TableColumn(0, 190, renderer, null); table.addColumn(column); 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:dbseer.gui.frame.DBSeerPlotCustomFrame.java
private void initializeGUI() { this.setLayout(new MigLayout("fill")); JFreeChart chart = null;//from w w w .j a v a 2s . c o m try { chart = DBSeerChartFactory.createCustomXYLineChart(xAxisName, yAxisName); } catch (Exception e) { e.printStackTrace(); } chartPanel = new ChartPanel(chart); this.add(chartPanel, "grow"); ArrayList<DBSeerChart> charts = new ArrayList<DBSeerChart>(); DBSeerChart newChart = new DBSeerChart("Custom", chart); newChart.setXAxisName(xAxisName); newChart.setYAxisName(yAxisName); charts.add(newChart); // if live/current dataset, launch the chart refresher. if (dataset.isCurrent()) { final DBSeerChartRefreshWorker refresher = new DBSeerChartRefreshWorker(charts, dataset); this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent windowEvent) { refresher.stop(); refresher.cancel(false); super.windowClosed(windowEvent); } }); refresher.execute(); } }
From source file:CommonLayouts.java
public CommonLayouts() { super("Common Layout Managers"); setSize(500, 380);//from www.jav a2 s . c om JPanel desktop = new JPanel(); getContentPane().add(desktop); JPanel fr1 = new JPanel(); fr1.setBorder(new TitledBorder("FlowLayout")); fr1.setLayout(new FlowLayout()); fr1.add(new JButton("1")); fr1.add(new JButton("2")); fr1.add(new JButton("3")); fr1.add(new JButton("4")); desktop.add(fr1, 0); JPanel fr2 = new JPanel(); fr2.setBorder(new TitledBorder("GridLayout")); fr2.setLayout(new GridLayout(2, 2)); fr2.add(new JButton("1")); fr2.add(new JButton("2")); fr2.add(new JButton("3")); fr2.add(new JButton("4")); desktop.add(fr2, 0); JPanel fr3 = new JPanel(); fr3.setBorder(new TitledBorder("BorderLayout")); fr3.add(new JButton("1"), BorderLayout.NORTH); fr3.add(new JButton("2"), BorderLayout.EAST); fr3.add(new JButton("3"), BorderLayout.SOUTH); fr3.add(new JButton("4"), BorderLayout.WEST); desktop.add(fr3, 0); JPanel fr4 = new JPanel(); fr4.setBorder(new TitledBorder("BoxLayout - X")); fr4.setLayout(new BoxLayout(fr4, BoxLayout.X_AXIS)); fr4.add(new JButton("1")); fr4.add(Box.createHorizontalStrut(12)); fr4.add(new JButton("2")); fr4.add(Box.createGlue()); fr4.add(new JButton("3")); fr4.add(Box.createHorizontalGlue()); fr4.add(new JButton("4")); desktop.add(fr4, 0); JPanel fr5 = new JPanel(); fr5.setBorder(new TitledBorder("BoxLayout - Y")); fr5.setLayout(new BoxLayout(fr5, BoxLayout.Y_AXIS)); fr5.add(new JButton("1")); fr5.add(Box.createVerticalStrut(10)); fr5.add(new JButton("2")); fr5.add(Box.createGlue()); fr5.add(new JButton("3")); fr5.add(Box.createVerticalGlue()); fr5.add(new JButton("4")); desktop.add(fr5, 0); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java
public PhoneOnlyView(ViewEventHandler viewEventHandler, TerminalProperties properties) { super(Config.TITLE + " - Terminal", viewEventHandler); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override/*from w w w.j a v a 2s .c o m*/ public void windowClosing(WindowEvent e) { eventHandler.closeButtonClicked(); } }); phoneOnlyContentPane = new PhoneOnlyContentPane(); this.setBounds(100, 100, 853, 130); this.getContentPane().add(phoneOnlyContentPane, BorderLayout.CENTER); setContentPane(phoneOnlyContentPane); phoneOnlyContentPane.getHookButton().addActionListener(this); this.setAlwaysOnTop(true); this.setResizable(false); log.info("PhoneOnlyView initialized"); }