List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:com.haulmont.cuba.desktop.exception.DefaultExceptionHandler.java
@Override public boolean handle(Thread thread, Throwable exception) { JXErrorPane errorPane = new JXErrorPaneExt(); errorPane.setErrorInfo(createErrorInfo(exception)); JDialog dialog = JXErrorPane.createDialog(App.getInstance().getMainFrame(), errorPane); dialog.setMinimumSize(new Dimension(600, (int) dialog.getMinimumSize().getHeight())); final DialogWindow lastDialogWindow = getLastDialogWindow(); dialog.addWindowListener(new WindowAdapter() { @Override// w w w. j a v a 2 s . c o m public void windowClosed(WindowEvent e) { if (lastDialogWindow != null) lastDialogWindow.enableWindow(); else App.getInstance().getMainFrame().activate(); } }); dialog.setModal(false); if (lastDialogWindow != null) lastDialogWindow.disableWindow(null); else App.getInstance().getMainFrame().deactivate(null); dialog.setVisible(true); return true; }
From source file:de.huxhorn.lilith.swing.LicenseAgreementDialog.java
public LicenseAgreementDialog() { super((Frame) null, "License Agreement", true); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { decline();/*from ww w. ja v a 2s. co m*/ } }); licenseAgreed = false; initUI(); }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//from w ww. j a v a 2 s. com */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }
From source file:test.mandelbrot.MandelbrotApp.java
public MandelbrotApp(final GridNode nodeRef) throws HeadlessException { super();/*w w w .j a va2s . c o m*/ this.setSize(WIDTH, HEIGHT); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { shutdown = true; setTitle("Shutting Down Node... Wait"); System.out.println("Shutting Down Node... Wait"); try { if (future != null) { if (!future.isJobFinished()) { future.cancel(); } } nodeRef.shutdown(); } catch (Exception e1) { e1.printStackTrace(); } System.exit(0); } }); setVisible(true); // create off-screen buffer offscreen = createImage(WIDTH, HEIGHT); offg = offscreen.getGraphics(); offg.setColor(Color.black); offg.fillRect(0, 0, WIDTH, HEIGHT); repaint(); setTitle("Wait..."); }
From source file:com.codeasylum.liquibase.Liquidate.java
public static void main(String... args) { ExtendedProfileLoader extensionLoader = null; boolean init = false; try {/* w w w .ja v a 2 s .co m*/ extensionLoader = new ExtendedProfileLoader(); init = true; } catch (Exception exception) { JavaErrorDialog.showJavaErrorDialog(null, null, exception); } if (init) { final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "com/codeasylum/liquibase/liquidate.xml"); Liquidate liquidate = applicationContext.getBean("liquidate", Liquidate.class); try { liquidate.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent windowEvent) { applicationContext.close(); } }); liquidate.init(extensionLoader).setVisible(true); } catch (Exception exception) { JavaErrorDialog.showJavaErrorDialog(liquidate, liquidate, exception); liquidate.dispose(); } } }
From source file:com.mirth.connect.plugins.rtfviewer.RTFViewer.java
@Override public void viewAttachments(List<String> attachmentIds) { // do viewing code Frame frame = new Frame("RTF Viewer"); frame.setLayout(new BorderLayout()); try {/* w w w. j a v a 2 s . c om*/ Attachment attachment = parent.mirthClient.getAttachment(attachmentIds.get(0)); byte[] rawRTF = Base64.decodeBase64(attachment.getData()); JEditorPane jEditorPane = new JEditorPane("text/rtf", new String(rawRTF)); 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.getData())); } 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.alertException(parent, e.getStackTrace(), e.getMessage()); } }
From source file:GUIMediaStatistics.java
/********************************************************************** * Construct the GUIMediaStatistics object, constructing the various * components and laying them out on the screen. **********************************************************************/ public GUIMediaStatistics() { super("GUIMediaStatistics"); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w ww. j a v a 2s .c o m } }); Panel filePanel = new Panel(); filePanel.add(new Label("File:")); mediaField = new TextField(40); filePanel.add(mediaField); browseButton = new Button("browse..."); filePanel.add(browseButton); browseButton.addActionListener(this); getStatsButton = new Button("get stats..."); filePanel.add(getStatsButton); getStatsButton.addActionListener(this); add(filePanel, "North"); results = new TextArea(80, 10); results.setEditable(false); add(results, "Center"); }
From source file:StocksTable4.java
public StocksTable4() { super("Stocks Table"); setSize(600, 300);/*from w w w . j a v a2s.co 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); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Presentation.MainWindow.java
/** Construction de la fentre d'affichage principale */ public MainWindow() { super();/*w w w.j av a 2 s . c o m*/ setTitle("Interface d'administration du frigo"); setSize(800, 1000); Panel mainPanel = new Panel(); BoxLayout layout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS); add(mainPanel); this.mPanel = mainPanel; addSlider(); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { dispose(); } }); show(); }
From source file:de.dakror.virtualhub.server.Server.java
public Server() { currentServer = this; dir = new File(CFG.DIR, "Server"); dir.mkdir();//from w w w . j a v a 2 s .com frame = new ServerFrame(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { shutdown(); } }); setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); frame.log("ERROR: " + sw.toString()); } }); try { socket = new ServerSocket(CFG.SERVER_PORT, 0, InetAddress.getLocalHost()); frame.log("Starte Server unter " + socket.getInetAddress().getHostAddress() + ":" + socket.getLocalPort()); } catch (BindException e) { frame.log("Es luft bereits ein Server auf diesem Port!"); shutdown(); return; } catch (Exception e) { e.printStackTrace(); } DBManager.init(); frame.log("Datenbank initialisiert"); start(); }