List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:Main.java
private void initUI() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getJTextArea_content().setText(TEXT); frame.add(getJScrollPane_descContent()); frame.pack();/*from w w w .j a va2s .c o m*/ frame.setVisible(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getJTextArea_content().scrollRectToVisible(new Rectangle()); } }); }
From source file:Main.java
@Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override/*w w w. j ava2 s .co m*/ public void run() { f.setText(f.getText() + "\n" + f.getText()); setSize(getPreferredSize()); } }); }
From source file:Main.java
/** * Invoke "runnable" on the AWT event dispatching thread.<br> * If you are in the AWT event dispatching thread the runnable can be executed immediately<br> * depending the value of <code>forceLater</code> parameter. * /*from ww w . j a v a 2 s . c o m*/ * @param forceLater * Force execution of runnable to be delayed<br> * even if we are on the AWT event dispatching thread */ public static void invokeLater(Runnable runnable, boolean forceLater) { if (SwingUtilities.isEventDispatchThread() && !forceLater) runnable.run(); else SwingUtilities.invokeLater(runnable); }
From source file:Main.java
public Main() { pbar = new JProgressBar(); pbar.setMinimum(min);// w ww . j av a2s.com pbar.setMaximum(max); add(pbar); JFrame frame = new JFrame("Progress Bar Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(this); frame.pack(); frame.setVisible(true); for (int i = min; i <= max; i++) { final int percent = i; try { SwingUtilities.invokeLater(new Runnable() { public void run() { updateBar(percent); } }); Thread.sleep(100); } catch (InterruptedException e) { } } }
From source file:Main.java
public void init() { tf1 = new JTextField(5); tf1.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { };/*from ww w. ja v a 2 s. c om*/ public void focusLost(FocusEvent e) { if (!e.isTemporary()) { String content = tf1.getText(); if (!content.equals("a")) { System.out.println("illegal value! " + content); SwingUtilities.invokeLater(new FocusGrabber(tf1)); } } } }); }
From source file:edu.ku.brc.specify.conversion.SpecifyDBConverter.java
/** * @param args//from w w w . j a va 2 s .co m * @throws Exception */ public static void main(String args[]) throws Exception { /*try { List<String> list = FileUtils.readLines(new File("/Users/rods/drop.sql")); Vector<String> list2 = new Vector<String>(); for (String line : list) { list2.add(line+";"); } FileUtils.writeLines(new File("/Users/rods/drop2.sql"), list2); return; } catch (Exception ex) { ex.printStackTrace(); }*/ // Set App Name, MUST be done very first thing! UIRegistry.setAppName("Specify"); //$NON-NLS-1$ log.debug("********* Current [" + (new File(".").getAbsolutePath()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ UIRegistry.setEmbeddedDBPath(UIRegistry.getDefaultEmbeddedDBPath()); // on the local machine AppBase.processArgs(args); final SpecifyDBConverter converter = new SpecifyDBConverter(); Logger logger = LogManager.getLogger("edu.ku.brc"); if (logger != null) { logger.setLevel(Level.ALL); System.out.println("Setting " + logger.getName() + " to " + logger.getLevel()); } logger = LogManager.getLogger(edu.ku.brc.dbsupport.HibernateUtil.class); if (logger != null) { logger.setLevel(Level.INFO); System.out.println("Setting " + logger.getName() + " to " + logger.getLevel()); } // Create Specify Application SwingUtilities.invokeLater(new Runnable() { public void run() { try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { log.error("Can't change L&F: ", e); } Pair<String, String> namePair = null; try { if (converter.selectedDBsToConvert(false)) { namePair = converter.chooseTable("Select a DB to Convert", "Specify 5 Databases", true); } } catch (SQLException ex) { ex.printStackTrace(); JOptionPane.showConfirmDialog(null, "The Converter was unable to login.", "Error", JOptionPane.CLOSED_OPTION); } if (namePair != null) { frame = new ProgressFrame("Converting"); converter.processDB(); } else { JOptionPane.showConfirmDialog(null, "The Converter was unable to login.", "Error", JOptionPane.CLOSED_OPTION); System.exit(0); } } }); }
From source file:MainClass.java
public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Update()); }
From source file:Main.java
public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (pbar.isCanceled()) { pbar.close();//from w w w . j ava2 s . c o m System.exit(1); } pbar.setProgress(counter); pbar.setNote("Operation is " + counter + "% complete"); counter += 2; } }); }
From source file:projects.upc.exec.HrDiagram.java
/** * Main application entry point./*ww w . j a va2 s . co m*/ * @param args * The args - ignored. */ public static void main(String[] args) { final JFrame frame = new JFrame("UPC HR diagram"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new HrDiagram(), BorderLayout.CENTER); frame.setSize(1500, 750); frame.pack(); frame.setVisible(true); } }); }
From source file:Main.java
private static void doSetIgnoreRepaint(final Component component, final boolean ignoreRepaint) { if (component != null) { if (SwingUtilities.isEventDispatchThread()) { doSetIgnoreRepaintInEDT(component, ignoreRepaint); } else {/*from w w w . j av a2s . c om*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetIgnoreRepaintInEDT(component, ignoreRepaint); } }); } } }