/** * Main method. Begins the GUI, and the rest of the program. * * @param args the command line arguments */ public static void main(String args[]) { // playSound(); try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex); } // </editor-fold> /* Create and display the form */ EventQueue.invokeLater( new Runnable() { @Override public void run() { new mainForm().setVisible(true); } }); }
@Override public void keyPressed(KeyEvent evt) { switch (evt.getKeyCode()) { case KeyEvent.VK_SPACE: goToSelectedNode(M_OPEN); // f**k me dead EventQueue.invokeLater( new Runnable() { @Override public void run() { resultTree.requestFocus(); } }); evt.consume(); break; case KeyEvent.VK_ENTER: goToSelectedNode(M_OPEN); evt.consume(); break; case KeyEvent.VK_DELETE: removeSelectedNode(); evt.consume(); break; default: break; } }
public void insertUpdate(final DocumentEvent e) { EventQueue.invokeLater( new Runnable() { public void run() { try { String inserted = e.getDocument().getText(e.getOffset(), e.getLength()); int i = inserted.indexOf('\n'); if (i >= 0) { int offset = e.getOffset() + i; if (offset + 1 == e.getDocument().getLength()) { returnResponse(); } else { // remove the '\n' and put it at the end e.getDocument().remove(offset, 1); e.getDocument().insertString(e.getDocument().getLength(), "\n", null); // insertUpdate will be called again, since we have inserted the '\n' at // the end } } else if (maxLen >= 0 && e.getDocument().getLength() - initialPos >= maxLen) { returnResponse(); } } catch (BadLocationException ex) { returnResponse(); } } }); }
// {{{ BrowserView constructor BrowserView(final VFSBrowser browser) { this.browser = browser; tmpExpanded = new HashSet<String>(); DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager(); KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME); parentDirectories = new ParentDirectoryList(); parentDirectories.addKeyListener(keyListener); parentDirectories.setName("parent"); parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); parentDirectories.setCellRenderer(new ParentDirectoryRenderer()); parentDirectories.setVisibleRowCount(5); parentDirectories.addMouseListener(new ParentMouseHandler()); final JScrollPane parentScroller = new JScrollPane(parentDirectories); parentScroller.setMinimumSize(new Dimension(0, 0)); table = new VFSDirectoryEntryTable(this); table.addMouseListener(new TableMouseHandler()); table.addKeyListener(new TableKeyListener()); table.setName("file"); JScrollPane tableScroller = new JScrollPane(table); tableScroller.setMinimumSize(new Dimension(0, 0)); tableScroller.getViewport().setBackground(table.getBackground()); tableScroller.getViewport().addMouseListener(new TableMouseHandler()); splitPane = new JSplitPane( browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT, parentScroller, tableScroller); splitPane.setOneTouchExpandable(true); EventQueue.invokeLater( new Runnable() { public void run() { String prop = browser.isHorizontalLayout() ? "vfs.browser.horizontalSplitter" : "vfs.browser.splitter"; int loc = jEdit.getIntegerProperty(prop, -1); if (loc == -1) loc = parentScroller.getPreferredSize().height; splitPane.setDividerLocation(loc); parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize()); } }); if (browser.isMultipleSelectionEnabled()) table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setLayout(new BorderLayout()); add(BorderLayout.CENTER, splitPane); propertiesChanged(); } // }}}
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { new Server(); } }); }
public static void main(String... args) { EventQueue.invokeLater( new Runnable() { @Override public void run() { createAndShowGUI(); } }); }
public static void main(String[] args) throws Exception { EventQueue.invokeLater( new Runnable() { public void run() { JFrame frame = new SwingWorkerFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
@Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater( new Runnable() { @Override public void run() { fireEditingStopped(); } }); }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { JFrame frame = new PostTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
String response() { EventQueue.invokeLater(this); try { return resultQueue.take(); } catch (InterruptedException ex) { return null; } finally { cleanup(); } }
void cleanup() { // not required to be called from the GUI thread EventQueue.invokeLater( new Runnable() { public void run() { run.getDocument().removeDocumentListener(listener); run.setEditable(false); run.setNavigationFilter(null); run.setCaretPosition(run.getDocument().getLength()); Simulator.getInstance().removeStopListener(stopListener); } }); }
public void removeUpdate(final DocumentEvent e) { EventQueue.invokeLater( new Runnable() { public void run() { if ((e.getDocument().getLength() < initialPos || e.getOffset() < initialPos) && e instanceof UndoableEdit) { ((UndoableEdit) e).undo(); run.setCaretPosition(e.getOffset() + e.getLength()); } } }); }
/** * Launch the application. * * <p>APIs * * <p>EmailValidator Class https://commons.apache.org/proper/commons-validator/apidocs/org/apache/ * commons/validator/routines/EmailValidator.html */ public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { try { LoginView window = new LoginView(); window.frmSignIn.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * Launch the application * * @param args */ public static void main(String args[]) { EventQueue.invokeLater( new Runnable() { public void run() { try { DateTimer frame = new DateTimer(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
public static void main(String[] args) { System.setProperty("java.security.policy", "permissions/PermissionTest.policy"); System.setSecurityManager(new SecurityManager()); EventQueue.invokeLater( new Runnable() { public void run() { JFrame frame = new PermissionTestFrame(); frame.setTitle("PermissionTest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
/** Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { try { TestSauvegardeChargement window = new TestSauvegardeChargement(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
public static void main(String args[]) { Runnable runner = new Runnable() { public void run() { if (SystemTray.isSupported()) { final SystemTray tray = SystemTray.getSystemTray(); Image image = Toolkit.getDefaultToolkit().getImage("gifIcon.gif"); PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup); MenuItem item = new MenuItem("Error"); item.addActionListener( new ShowMessageListener( trayIcon, "Error Title", "Error", TrayIcon.MessageType.ERROR)); popup.add(item); item = new MenuItem("Warning"); item.addActionListener( new ShowMessageListener( trayIcon, "Warning Title", "Warning", TrayIcon.MessageType.WARNING)); popup.add(item); item = new MenuItem("Info"); item.addActionListener( new ShowMessageListener( trayIcon, "Info Title", "Info", TrayIcon.MessageType.INFO)); popup.add(item); item = new MenuItem("None"); item.addActionListener( new ShowMessageListener( trayIcon, "None Title", "None", TrayIcon.MessageType.NONE)); popup.add(item); item = new MenuItem("Close"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { tray.remove(trayIcon); } }); popup.add(item); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("Can't add to tray"); } } else { System.err.println("Tray unavailable"); } } }; EventQueue.invokeLater(runner); }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { try { SotrudnikDialog frame = new SotrudnikDialog(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { @Override public void run() { try { ScreenShotWindow ssw = new ScreenShotWindow(); ssw.setVisible(true); } catch (AWTException e) { e.printStackTrace(); } } }); }
private void performGazeteerAction(final ActionEvent e) { EventQueue.invokeLater( new Runnable() { public void run() { try { handleEntryAction(e); } catch (NoItemException e) { controller.showMessageDialog( "No search string was specified", "No Search String", JOptionPane.ERROR_MESSAGE); } catch (Exception e) { controller.showMessageDialog( "Location not found", "Location Unknown", JOptionPane.ERROR_MESSAGE); } } }); }
/* (non-Javadoc) * @see java.awt.Component#doLayout() */ public void doLayout() { if (EventQueue.isDispatchThread()) { Dimension size = this.getSize(); this.rblock.setBounds(0, 0, size.width, size.height); this.removeAll(); this.rblock.layout(size.width, size.height); this.rblock.updateWidgetBounds(); } else { EventQueue.invokeLater( new Runnable() { public void run() { HtmlBlock.this.doLayout(); } }); } }
// used to actually bring up the window public void run() { // this creates the window Runnable runner = new Runnable() { public void run() { // create the main frame frame = new JFrame("Search result: " + myFName); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // create the area to display the text JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.insert(stringToCheck, 0); JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); // create the button and the area where it is displated JPanel dotPanel = new JPanel(new BorderLayout()); JButton myButton; if (myFileList.size() != 0) myButton = new JButton("Onto next file"); else myButton = new JButton("Done"); dotPanel.add(myButton, BorderLayout.CENTER); frame.add(dotPanel, BorderLayout.SOUTH); // this listens for a user to click the "done" button ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { iAmDone.release(1); frame.dispose(); } }; // add the button and make the frame visible myButton.addActionListener(buttonListener); frame.setSize(500, 500); frame.setVisible(true); } }; // run the window EventQueue.invokeLater(runner); }
public void run() { try { while (true) { EventQueue.invokeLater( new Runnable() { public void run() { combo.showPopup(); int i = Math.abs(generator.nextInt()); if (i % 2 == 0) combo.insertItemAt(new Integer(i), 0); else if (combo.getItemCount() > 0) combo.removeItemAt(i % combo.getItemCount()); } }); Thread.sleep(1); } } catch (InterruptedException e) { } }
@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { System.out.println("getTableCellEditorComponent"); setFont(table.getFont()); setText(Objects.toString(value, "")); EventQueue.invokeLater( new Runnable() { @Override public void run() { setCaretPosition(getText().length()); requestFocusInWindow(); System.out.println("invokeLater: getTableCellEditorComponent"); } }); return scroll; }
/** Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { try { DelStop frame = new DelStop(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(493, 313); frame.setVisible(true); frame.setResizable(false); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * @param searchNode the result node * @param selectNode the node that must be selected, or null * @since jEdit 4.3pre12 */ public void searchDone( final DefaultMutableTreeNode searchNode, final DefaultMutableTreeNode selectNode) { stop.setEnabled(false); final int nodeCount = searchNode.getChildCount(); if (nodeCount < 1) { searchFailed(); return; } caption.setText( jEdit.getProperty("hypersearch-results.done", new String[] {trimSearchString()})); EventQueue.invokeLater( new Runnable() { @Override public void run() { if (!multiStatus) { for (int i = 0; i < resultTreeRoot.getChildCount(); i++) { resultTreeRoot.remove(0); } } resultTreeRoot.add(searchNode); resultTreeModel.reload(resultTreeRoot); for (int i = 0; i < nodeCount; i++) { TreePath lastNode = new TreePath(((DefaultMutableTreeNode) searchNode.getChildAt(i)).getPath()); resultTree.expandPath(lastNode); } TreePath treePath; if (selectNode == null) { treePath = new TreePath(new Object[] {resultTreeRoot, searchNode}); } else { treePath = new TreePath(selectNode.getPath()); } resultTree.setSelectionPath(treePath); resultTree.scrollPathToVisible(treePath); } }); } // }}}
@Override public boolean isCellEditable(final EventObject e) { if (e instanceof MouseEvent) { return ((MouseEvent) e).getClickCount() >= 2; } System.out.println("isCellEditable"); EventQueue.invokeLater( new Runnable() { @Override public void run() { if (e instanceof KeyEvent) { KeyEvent ke = (KeyEvent) e; char kc = ke.getKeyChar(); if (Character.isUnicodeIdentifierStart(kc)) { setText(getText() + kc); System.out.println("invokeLater: isCellEditable"); } } } }); return true; }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { // make frame with a button panel ButtonFrame frame = new ButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); // attach a robot to the screen device GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = environment.getDefaultScreenDevice(); try { Robot robot = new Robot(screen); runTest(robot); } catch (AWTException e) { e.printStackTrace(); } } }); }
/** create frame to handle the puzzle settings. For now only the puzzle size can be configured. */ public void createFrame() { EventQueue.invokeLater( new Runnable() { @Override public void run() { final JFrame frame = new JFrame("Configuration"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.setOpaque(true); final JLabel label = new JLabel( "Set the number of tiles of the puzzle: Currently supported tiles are 3,8,15"); final JTextField input = new JTextField(20); JButton button = new JButton("Enter"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String text = input.getText(); int dim = 0; try { dim = Integer.parseInt(text); } catch (NumberFormatException e5) { JOptionPane.showMessageDialog(new JFrame(), "Gets Integer Only"); } dim = (int) Math.sqrt(dim + 1); if (dim > 4) { JOptionPane.showMessageDialog( null, "Creating puzzle with maximum supported tiles", "Dimension not supported", JOptionPane.ERROR_MESSAGE); dim = 15; } else if (dim < 2) { JOptionPane.showMessageDialog( null, "Creating puzzle with minimum supported tiles", "Dimension not supported", JOptionPane.ERROR_MESSAGE); dim = 3; } else { dim = (dim * dim) - 1; } setConfiguration(dim); frame.setVisible(false); // you can't see me! frame.dispose(); // Destroy the JFrame object } }); panel.add(label); panel.add(input); panel.add(button); frame.getContentPane().add(BorderLayout.CENTER, panel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setResizable(false); input.requestFocus(); } }); }
// {{{ InstallPanel constructor InstallPanel(PluginManager window, boolean updates) { super(new BorderLayout(12, 12)); this.window = window; this.updates = updates; setBorder(new EmptyBorder(12, 12, 12, 12)); final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.75); /* Setup the table */ table = new JTable(pluginModel = new PluginTableModel()); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setRowHeight(table.getRowHeight() + 2); table.setPreferredScrollableViewportSize(new Dimension(500, 200)); table.setDefaultRenderer( Object.class, new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class))); table.addFocusListener(new TableFocusHandler()); InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED); ActionMap tableActionMap = table.getActionMap(); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward"); tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack"); tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin"); tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager"); tableActionMap.put( "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER)); TableColumn col1 = table.getColumnModel().getColumn(0); TableColumn col2 = table.getColumnModel().getColumn(1); TableColumn col3 = table.getColumnModel().getColumn(2); TableColumn col4 = table.getColumnModel().getColumn(3); TableColumn col5 = table.getColumnModel().getColumn(4); col1.setPreferredWidth(30); col1.setMinWidth(30); col1.setMaxWidth(30); col1.setResizable(false); col2.setPreferredWidth(180); col3.setPreferredWidth(130); col4.setPreferredWidth(70); col5.setPreferredWidth(70); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); header.addMouseListener(new HeaderMouseHandler()); header.setDefaultRenderer( new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer())); scrollpane = new JScrollPane(table); scrollpane.getViewport().setBackground(table.getBackground()); split.setTopComponent(scrollpane); /* Create description */ JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox()); infoPane.setPreferredSize(new Dimension(500, 100)); split.setBottomComponent(infoPane); EventQueue.invokeLater( new Runnable() { @Override public void run() { split.setDividerLocation(0.75); } }); final JTextField searchField = new JTextField(); searchField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { table.dispatchEvent(e); table.requestFocus(); } } }); searchField .getDocument() .addDocumentListener( new DocumentListener() { void update() { pluginModel.setFilterString(searchField.getText()); } @Override public void changedUpdate(DocumentEvent e) { update(); } @Override public void insertUpdate(DocumentEvent e) { update(); } @Override public void removeUpdate(DocumentEvent e) { update(); } }); table.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int i = table.getSelectedRow(), n = table.getModel().getRowCount(); if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1) || e.getKeyCode() == KeyEvent.VK_UP && i == 0) { searchField.requestFocus(); searchField.selectAll(); } } }); Box filterBox = Box.createHorizontalBox(); filterBox.add(new JLabel("Filter : ")); filterBox.add(searchField); add(BorderLayout.NORTH, filterBox); add(BorderLayout.CENTER, split); /* Create buttons */ Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(new InstallButton()); buttons.add(Box.createHorizontalStrut(12)); buttons.add(new SelectallButton()); buttons.add(chooseButton = new ChoosePluginSet()); buttons.add(new ClearPluginSet()); buttons.add(Box.createGlue()); buttons.add(new SizeLabel()); add(BorderLayout.SOUTH, buttons); String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, ""); if (!path.isEmpty()) { loadPluginSet(path); } } // }}}