List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:eu.apenet.dpt.standalone.gui.eag2012.Eag2012Frame.java
public void createFrame(InputStream eagStream, boolean isNew) { timeMaintenance = null;/*from w w w . ja v a 2s . co m*/ personResponsible = null; inUse(true); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { inUse(false); } }); Eag eag = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(Eag.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); eag = (Eag) jaxbUnmarshaller.unmarshal(eagStream); eagStream.close(); } catch (Exception e) { e.printStackTrace(); } buildPanel(eag, isNew); this.getContentPane().add(mainTabbedPane); Dimension frameDim = new Dimension(((Double) (dimension.getWidth() * 0.95)).intValue(), ((Double) (dimension.getHeight() * 0.95)).intValue()); this.setSize(frameDim); this.setPreferredSize(frameDim); this.pack(); this.setVisible(true); this.setExtendedState(JFrame.MAXIMIZED_BOTH); }
From source file:de.codesourcery.eve.skills.ui.utils.PersistentDialog.java
public PersistentDialog(String id, Icon icon, String title, String label, PersistenceType type, Kind kind) { super(null, title, ModalityType.APPLICATION_MODAL); if (kind == null) { throw new IllegalArgumentException("kind cannot be NULL"); }/*from ww w. j av a 2s. c o m*/ if (StringUtils.isBlank(id)) { throw new IllegalArgumentException("id cannot be blank."); } if (type == null) { throw new IllegalArgumentException("type cannot be NULL"); } if (StringUtils.isBlank(label)) { throw new IllegalArgumentException("label cannot be blank."); } this.id = id; this.type = type; // configure checkbox isDialogEnabled = new JCheckBox("Always show this dialog ?", true); isDialogEnabled.setHorizontalTextPosition(SwingConstants.RIGHT); // add panel final JPanel content = new JPanel(); content.setLayout(new GridBagLayout()); content.add(new JLabel(icon), new ConstraintsBuilder().x(0).y(0).anchorWest().noResizing().useRelativeWidth().end()); content.add(new JLabel(label), new ConstraintsBuilder().x(1).y(0).anchorWest().resizeBoth().useRemainingWidth().end()); content.add(isDialogEnabled, new ConstraintsBuilder().x(0).y(1).width(2).anchorWest().noResizing().end()); final JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); final ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == cancelButton) { wasCancelled = true; } dispose(); } }; okButton.addActionListener(listener); if (kind == Kind.CANCEL) { buttonPanel.add(cancelButton); cancelButton.addActionListener(listener); } content.add(buttonPanel, new ConstraintsBuilder().x(0).y(2).useRemainingSpace().end()); getContentPane().add(content); pack(); setLocationRelativeTo(null); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { wasCancelled = true; dispose(); } }); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java
private void initMainWindow() { this.addWindowFocusListener(new WindowAdapter() { @Override//from w w w . j a v a 2 s . co m public void windowGainedFocus(WindowEvent e) { updateModel(); } }); this.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK), "NEW_AUTHOR"); this.getRootPane().getActionMap().put("NEW_AUTHOR", spawnNewAuthorWindowAction); }
From source file:de.peterspan.csv2db.AppWindow.java
private void initialize() { frame = new JFrame(); frame.setIconImage(Icons.IC_APPLICATION_X_LARGE.getImage()); AppWindow._frame = frame;//from w ww. ja va 2 s . co m frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (reallyExit() == JOptionPane.YES_OPTION) { SingleInstance.release(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } }); frame.setTitle(Messages.getString("AppWindow.0") + " " + Messages.getString("AppWindow.version.code")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ frame.setLocationRelativeTo(null); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu mnFile = new JMenu(Messages.getString("AppWindow.1")); //$NON-NLS-1$ menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem(Messages.getString("AppWindow.3")); //$NON-NLS-1$ mntmExit.setIcon(Icons.IC_LOGOUT_SMALL); mntmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); } }); mnFile.add(mntmExit); JMenu mnEdit = new JMenu(Messages.getString("AppWindow.4")); //$NON-NLS-1$ menuBar.add(mnEdit); JMenuItem mntmOptions = new JMenuItem(Messages.getString("AppWindow.5")); //$NON-NLS-1$ mntmOptions.setIcon(Icons.IC_PREFERENCES_SYSTEM_SMALL); mntmOptions.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // new OptionsDialog(frame); } }); mnEdit.add(mntmOptions); JMenu mnHelp = new JMenu(Messages.getString("AppWindow.6")); //$NON-NLS-1$ menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem(Messages.getString("AppWindow.7")); //$NON-NLS-1$ mntmAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { new AboutDialog(frame); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mnHelp.add(mntmAbout); createContent(); DialogUtil.getInstance().setMainFrame(frame); }
From source file:com.diversityarrays.wizard.WizardRunner.java
public Window showRelativeTo(Component relativeTo) { RootPaneContainer rpc = ((RootPaneContainer) window); Container cp = rpc.getContentPane(); cp.setLayout(new BorderLayout()); cp.add(status, BorderLayout.NORTH); cp.add(this, BorderLayout.CENTER); window.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cancel();// ww w .j a v a 2 s. c om } }); status.setText("Active"); addWizardListener(wizardListener); window.pack(); Dimension d = window.getSize(); ++d.width; window.setSize(d); window.setLocationRelativeTo(relativeTo); window.setVisible(true); window.toFront(); return window; }
From source file:support.SystemMonitorGui.java
private XYPlot createChartFrame(XYSeries series) { XYSeriesCollection dataSet = new XYSeriesCollection(); dataSet.addSeries(series);//w w w . j a va 2s . co m JFreeChart chart = ChartFactory.createXYLineChart("Memory Allocation Rate", "Time (ms)", "Allocation Rate (MB/s)", dataSet, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); frame.setVisible(true); return plot; }
From source file:com.nvinayshetty.DTOnator.Ui.InputWindow.java
public InputWindow(PsiClass mClass) { this.mClass = mClass; project = mClass.getProject();//from w w w .ja v a2 s . c o m mFile = mClass.getContainingFile(); setContentPane(contentPane); inputFeedText.getRootPane().setSize(750, 400); setSize(1000, 600); setTitle("Generate DTO"); getRootPane().setDefaultButton(buttonOk); initButtons(); initListeners(); setDefaultConditions(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); contentPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
From source file:Main.java
public Main() { setSize(500, 340);// w w w. j ava 2 s. com Date currentDate = new Date(); calendar.setTime(currentDate); JPanel p1 = new JPanel(); p1.setLayout(new GridLayout(4, 1)); JPanel p = new JPanel(); p.setBorder(new TitledBorder(new EtchedBorder(), "Selected Date")); dateLabel = new JLabel(dateFormat.format(currentDate) + " "); dateLabel.setFont(new Font("Arial", Font.BOLD, 24)); p.add(dateLabel); p1.add(p); yearSlider.setPaintLabels(true); yearSlider.setMajorTickSpacing(5); yearSlider.setMinorTickSpacing(1); yearSlider.setPaintTicks(true); DateListener lst = new DateListener(); yearSlider.addChangeListener(lst); p = new JPanel(); p.setBorder(new TitledBorder(new EtchedBorder(), "Year")); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(Box.createRigidArea(RIGID_DIMENSION)); p.add(yearSlider); p.add(Box.createRigidArea(RIGID_DIMENSION)); p1.add(p); String[] months = (new DateFormatSymbols()).getShortMonths(); hashTable = new Hashtable(12); for (int i = 0; i < 12; i++) hashTable.put(new Integer(i + 1), new JLabel(months[i], JLabel.CENTER)); monthSlider.setLabelTable(hashTable); monthSlider.setPaintLabels(true); monthSlider.setMajorTickSpacing(1); monthSlider.setPaintTicks(true); monthSlider.addChangeListener(lst); p = new JPanel(); p.setBorder(new TitledBorder(new EtchedBorder(), "Month")); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(Box.createRigidArea(RIGID_DIMENSION)); p.add(monthSlider); p.add(Box.createRigidArea(RIGID_DIMENSION)); p1.add(p); int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); daySlider = new JSlider(JSlider.HORIZONTAL, 1, maxDays, calendar.get(Calendar.DAY_OF_MONTH)); daySlider.setPaintLabels(true); daySlider.setMajorTickSpacing(5); daySlider.setMinorTickSpacing(1); daySlider.setPaintTicks(true); daySlider.addChangeListener(lst); p = new JPanel(); p.setBorder(new TitledBorder(new EtchedBorder(), "Day")); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(Box.createRigidArea(RIGID_DIMENSION)); p.add(daySlider); p.add(Box.createRigidArea(RIGID_DIMENSION)); p1.add(p); getContentPane().add(p1, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); enableEvents(ComponentEvent.COMPONENT_RESIZED); setVisible(true); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @throws HeadlessException/* ww w .jav a 2 s .c o m*/ */ public ScriptFilterRunner(final boolean terminate, String serviceUrl) throws HeadlessException { super("Intuit Tank Script Filter Editor"); setSize(new Dimension(1024, 800)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { if (terminate) { System.exit(0); } } }); scriptServiceClient = new ScriptServiceClient(serviceUrl); Component topPanel = createTopPanel(); Component bottomPanel = createBottomPanel(); Component contentPanel = createContentPanel(); add(topPanel, BorderLayout.NORTH); add(contentPanel, BorderLayout.CENTER); add(bottomPanel, BorderLayout.SOUTH); WindowUtil.centerOnScreen(this); pack(); }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
public BudgetFrame(int id, DefaultTransactionService service) { super();//w ww. jav a 2 s . co m this.id = id; this.service = service; setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { SwingMain.close(BudgetFrame.this.id); } }); buildTransactionTable(); buildReconciliationTable(); buildSimulationPanel(); buildMenubar(); layoutComponents(); }