List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfFrame.java
public void createFrame(InputStream eacCpfStream, boolean isNew) { timeMaintenance = null;/*w w w . ja v a2 s . c om*/ personResponsible = null; inUse(true); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { inUse(false); } }); EacCpf eacCpf = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(EacCpf.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); eacCpf = (EacCpf) jaxbUnmarshaller.unmarshal(eacCpfStream); eacCpfStream.close(); } catch (Exception e) { e.printStackTrace(); } this.buildPanel(eacCpf, 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:com.emental.mindraider.ui.dialogs.AddTripletJDialog.java
/** * Constructor./*from w w w . j av a2 s . c om*/ */ public AddTripletJDialog() { super("Add Triplet"); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(4, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Predicate: ")); predicateNs = new JTextField(30); predicateNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); predicateNs.selectAll(); p.add(predicateNs); p.add(new JLabel("#")); predicateLocalName = new JTextField(15); p.add(predicateLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Object: ")); objectNs = new JTextField(30); objectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); objectNs.selectAll(); p.add(objectNs); p.add(new JLabel("#")); objectLocalName = new JTextField(15); objectLocalName.grabFocus(); objectLocalName.selectAll(); objectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createTriplet(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(objectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton("Add"); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createTriplet(); } }); JButton cancelButton = new JButton("Cancel"); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddTripletJDialog.this.dispose(); } }); framePanel.add(p); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { getObjectLocalName().requestFocusInWindow(); } }); }
From source file:de.tbuchloh.kiskis.gui.MainFrame.java
private void init() { _tray = SystemTrayFactory.create(this); this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.setIconImage(loadImage(ICON_PNG).getImage()); this.addWindowListener(new WindowAdapter() { @Override//from ww w. ja v a 2 s. c o m public void windowClosing(final WindowEvent e) { onClosing(); } }); _main = new MainFramePanel(this); this.getContentPane().setLayout(new BorderLayout()); setMainView(_main); final StatusBar statusBar = new StatusBar(); _statusMsg = new SimpleTextField(SimpleTextField.LEFT); statusBar.add(_statusMsg, 0, 1); this.getContentPane().add(statusBar, BorderLayout.SOUTH); this.pack(); }
From source file:jgnash.ui.commodity.SecuritiesHistoryDialog.java
private SecuritiesHistoryDialog(final JFrame parent) { super(parent); setTitle(rb.getString("Title.ModifySecHistory")); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().add(layoutMainPanel(), BorderLayout.CENTER); changeNode();//w w w .ja v a2 s . c om pack(); setMinimumSize(getSize()); DialogUtils.addBoundsListener(SecuritiesHistoryDialog.this); addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { model.unregisterListeners(); } }); }
From source file:Unicode.java
/** Construct the object including its GUI */ public Unicode() { super("Unicode"); Container cp = getContentPane(); // Used both for Buttons and Menus ResourceBundle b = ResourceBundle.getBundle("UnicodeWidgets"); JButton quitButton, nextButton, prevButton; Panel p = new Panel(); // Make a grid, add one for labels. p.setLayout(new GridLayout(ROWS + 1, COLUMNS + 1)); DecimalFormat df2d = new DecimalFormat("00"); // Add first row, just column labels. p.add(new JLabel("")); for (int i = 0; i < COLUMNS; i++) p.add(new JLabel(Integer.toString(i, 16), JLabel.CENTER)); // Add subsequent rows, each with an offset label for (int i = 0; i < ROWS; i++) { JLabel l = new JLabel("0000"); // room for max, i.e. \uFFFF p.add(l);//from www.j ava 2 s . c o m rowLabs[i] = l; for (int j = 0; j < COLUMNS; j++) { JLabel pb = new JLabel(" "); buttons[j][i] = pb; p.add(pb); } } // ActionListeners for jumping around; used by buttons and menus ActionListener firster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(startNum = 0); } }; ActionListener previouser = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum > 0) gotoPage(startNum -= QUADSIZE); } }; ActionListener nexter = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum < 65535) gotoPage(startNum += QUADSIZE); } }; ActionListener laster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(65536 - QUADSIZE); } }; cp.add(BorderLayout.NORTH, p); fontName = new JLabel("Default font", JLabel.CENTER); cp.add(BorderLayout.CENTER, fontName); Panel q = new Panel(); cp.add(BorderLayout.SOUTH, q); q.add(prevButton = mkButton(b, "page.prev")); prevButton.addActionListener(previouser); q.add(nextButton = mkButton(b, "page.next")); nextButton.addActionListener(nexter); q.add(quitButton = mkButton(b, "exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); System.exit(0); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); MenuItem mi; // used in various spots MenuBar mb = new MenuBar(); setMenuBar(mb); String titlebar; try { titlebar = b.getString("program" + ".title"); } catch (MissingResourceException e) { titlebar = "Unicode Demo"; } setTitle(titlebar); ActionListener fontSelector = new ActionListener() { public void actionPerformed(ActionEvent e) { String font = e.getActionCommand(); mySetFont(font, FONTSIZE); } }; Menu fontMenu = mkMenu(b, "font"); // String[] fontList = Toolkit.getDefaultToolkit().getFontList(); String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fontList.length; i++) { fontMenu.add(mi = new MenuItem(fontList[i])); mi.addActionListener(fontSelector); } mb.add(fontMenu); gotoPageUI = new GoToPage("Unicode Page"); centre(gotoPageUI); Menu vm = mkMenu(b, "page"); vm.add(mi = mkMenuItem(b, "page", "first")); mi.addActionListener(firster); vm.add(mi = mkMenuItem(b, "page", "prev")); mi.addActionListener(previouser); vm.add(mi = mkMenuItem(b, "page", "next")); mi.addActionListener(nexter); vm.add(mi = mkMenuItem(b, "page", "last")); mi.addActionListener(laster); vm.add(mi = mkMenuItem(b, "page", "goto")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Unicode.this.gotoPageUI.setVisible(true); } }); mb.add(vm); Menu hm = mkMenu(b, "help"); hm.add(mi = mkMenuItem(b, "help", "about")); mb.setHelpMenu(hm); // needed for portability (Motif, etc.). pack(); // After packing the Frame, centre it on the screen. centre(this); // start at a known place mySetFont(fontList[0], FONTSIZE); gotoPage(startNum); }
From source file:es.emergya.ui.gis.popups.RouteDialog.java
private RouteDialog() { super();/*from ww w . j av a2 s . c om*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_calculando"); try { route = new OsmDataLayer(new DataSet(), "route", File.createTempFile("route", "route")); } catch (IOException e) { log.error(e.getMessage(), e); } setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { clear.doClick(); setVisible(false); } }); setTitle(i18n.getString("window.route.titleBar")); setMinimumSize(new Dimension(400, 200)); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); title.setOpaque(false); final JLabel labelTitle = new JLabel(i18n.getString("window.route.title"), LogicConstants.getIcon("tittleventana_icon_calcularruta"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12.0f)); title.add(labelTitle); base.add(title); JPanel content = new JPanel(new SpringLayout()); content.setOpaque(false); // Coordenadas content.add(new JLabel(i18n.getString("window.route.origen"), JLabel.LEFT)); JPanel coords = new JPanel(new GridLayout(1, 2)); coords.setOpaque(false); fx = new JTextField(8); fx.setEditable(false); fy = new JTextField(8); fy.setEditable(false); coords.add(fy); coords.add(fx); content.add(coords); content.add(new JLabel(i18n.getString("window.route.destino"), JLabel.LEFT)); JPanel coords2 = new JPanel(new GridLayout(1, 2)); coords2.setOpaque(false); tx = new JTextField(8); tx.setEditable(false); ty = new JTextField(8); ty.setEditable(false); coords2.add(ty); coords2.add(tx); content.add(coords2); SpringUtilities.makeCompactGrid(content, 2, 2, 6, 6, 6, 6); base.add(content); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("PLACEHOLDER"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); search = new JButton(i18n.getString("window.route.calcular"), LogicConstants.getIcon("ventanacontextual_button_calcularruta")); search.addActionListener(this); buttons.add(search); clear = new JButton(i18n.getString("window.route.limpiar"), LogicConstants.getIcon("button_limpiar")); clear.addActionListener(this); buttons.add(clear); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:FTPApp.java
public FTPApp() { super("FTP Client"); JPanel p = new JPanel(); p.setBorder(new EmptyBorder(5, 5, 5, 5)); p.add(new JLabel("User name:")); p.add(userNameTextField);//from w w w.j a v a2s.com p.add(new JLabel("Password:")); p.add(passwordTextField); p.add(new JLabel("URL:")); p.add(urlTextField); p.add(new JLabel("File:")); p.add(fileTextField); monitorTextArea.setEditable(false); JScrollPane ps = new JScrollPane(monitorTextArea); p.add(ps); m_progress.setStringPainted(true); m_progress.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.white, Color.gray)); m_progress.setMinimum(0); JPanel p1 = new JPanel(new BorderLayout()); p1.add(m_progress, BorderLayout.CENTER); p.add(p1); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (connect()) { Thread uploader = new Thread() { public void run() { putFile(); disconnect(); } }; uploader.start(); } } }; putButton.addActionListener(lst); putButton.setMnemonic('p'); p.add(putButton); getButton = new JButton("Get"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (connect()) { Thread downloader = new Thread() { public void run() { getFile(); disconnect(); } }; downloader.start(); } } }; getButton.addActionListener(lst); getButton.setMnemonic('g'); p.add(getButton); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (fileChooser.showSaveDialog(FTPApp.this) != JFileChooser.APPROVE_OPTION) return; File f = fileChooser.getSelectedFile(); fileTextField.setText(f.getPath()); } }; fileButton.addActionListener(lst); fileButton.setMnemonic('f'); p.add(fileButton); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (ftpClient != null) disconnect(); else System.exit(0); } }; closeButton.addActionListener(lst); closeButton.setDefaultCapable(true); closeButton.setMnemonic('g'); p.add(closeButton); getContentPane().add(p, BorderLayout.CENTER); fileChooser.setCurrentDirectory(new File(".")); fileChooser.setApproveButtonToolTipText("Select file for upload/download"); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { disconnect(); System.exit(0); } }; addWindowListener(wndCloser); setSize(720, 240); setVisible(true); }
From source file:com._17od.upm.gui.DatabaseActions.java
/** * This method asks the user for the name of a new database and then creates * it. If the file already exists then the user is asked if they'd like to * overwrite it.//from w ww. j a v a 2 s. co m * @throws CryptoException * @throws IOException */ public void newDatabase() throws IOException, CryptoException { File newDatabaseFile = getSaveAsFile(Translator.translate("newPasswordDatabase")); if (newDatabaseFile == null) { return; } final JPasswordField masterPassword = new JPasswordField(""); boolean passwordsMatch = false; do { //Get a new master password for this database from the user JPasswordField confirmedMasterPassword = new JPasswordField(""); JOptionPane pane = new JOptionPane( new Object[] { Translator.translate("enterMasterPassword"), masterPassword, Translator.translate("confirmation"), confirmedMasterPassword }, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog(mainWindow, Translator.translate("masterPassword")); dialog.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { masterPassword.requestFocusInWindow(); } }); dialog.show(); if (pane.getValue().equals(new Integer(JOptionPane.OK_OPTION))) { if (!Arrays.equals(masterPassword.getPassword(), confirmedMasterPassword.getPassword())) { JOptionPane.showMessageDialog(mainWindow, Translator.translate("passwordsDontMatch")); } else { passwordsMatch = true; } } else { return; } } while (passwordsMatch == false); if (newDatabaseFile.exists()) { newDatabaseFile.delete(); } database = new PasswordDatabase(newDatabaseFile); dbPers = new PasswordDatabasePersistence(masterPassword.getPassword()); saveDatabase(); accountNames = new ArrayList(); doOpenDatabaseActions(); // If a "Database to Load on Startup" hasn't been set yet then ask the // user if they'd like to open this database on startup. if (Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP) == null || Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP).equals("")) { int option = JOptionPane.showConfirmDialog(mainWindow, Translator.translate("setNewLoadOnStartupDatabase"), Translator.translate("newPasswordDatabase"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { Preferences.set(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP, newDatabaseFile.getAbsolutePath()); Preferences.save(); } } }
From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java
/** * Creates a {@link JGraphXVisualizer} object. */// w w w. j av a 2s . c o m public JGraphXVisualizer() { graph = new mxGraph(); graph.setCellsEditable(false); graph.setAllowDanglingEdges(false); graph.setAllowLoops(false); graph.setCellsDeletable(false); graph.setCellsCloneable(false); graph.setCellsDisconnectable(false); graph.setDropEnabled(false); graph.setSplitEnabled(false); graph.setCellsBendable(false); graph.setConnectableEdges(false); graph.setCellsMovable(false); graph.setCellsResizable(false); graph.setAutoSizeCells(true); component = new mxGraphComponent(graph); component.setConnectable(false); component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); nodeLookupMap = new DualHashBidiMap<>(); connToEdgeLookupMap = new MultiValueMap<>(); edgeToConnLookupMap = new HashMap<>(); vertexLingerTriggerMap = new HashMap<>(); textOutputArea = new JTextArea(); textOutputArea.setLineWrap(false); textOutputArea.setEditable(false); JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea); textOutputScrollPane.setPreferredSize(new Dimension(0, 100)); frame = new JFrame("Visualizer"); frame.setSize(400, 400); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane); splitPane.setResizeWeight(1.0); frame.setContentPane(splitPane); component.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { zoomFit(); } }); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { Recorder<A> rec = recorder.get(); if (rec != null) { IOUtils.closeQuietly(rec); } VisualizerEventListener veListener = listener.get(); if (veListener != null) { veListener.closed(); } } }); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); splitPane.setDividerLocation(0.2); }
From source file:com.intuit.tank.proxy.ProxyApp.java
public ProxyApp() { super("Intuit Tank Recording Proxy"); setSize(new Dimension(800, 600)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize());//from ww w . j a v a2s.c o m setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { try { stop(); } catch (Exception e1) { e1.printStackTrace(); } System.exit(0); } }); keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); configDialog = new ProxyConfigDialog(this); createActions(); this.setJMenuBar(createMenu()); createDetailsDialog(); JPanel tablePanel = getTransactionTable(); this.add(createToolBar(), BorderLayout.NORTH); this.add(tablePanel, BorderLayout.CENTER); WindowUtil.centerOnScreen(this); pack(); setVisible(true); requestFocus(); }