List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:Main.java
/** * Work around for JTable/viewport bug./*from w w w. jav a 2 s. c o m*/ * @link http://developer.java.sun.com/developer/bugParade/bugs/4205145.html */ protected static void repaintLater(final JComponent component) { SwingUtilities.invokeLater(new Runnable() { public void run() { component.repaint(); } }); }
From source file:finale.year.stage.main.Authentification.java
/** * * @param message/*from w w w . j av a 2s . c o m*/ */ public static void updateStatus(final String message) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { errorStatusBar.setText(""); errorStatusBar.setForeground(Color.red); errorStatusBar.setText(message); } catch (NullPointerException e) { return; } } }); }
From source file:Main.java
public Main() { setSize(300, 100);//from w ww. j a v a2s .c o m UIManager.put("ProgressBar.selectionBackground", Color.black); UIManager.put("ProgressBar.selectionForeground", Color.white); UIManager.put("ProgressBar.foreground", new Color(8, 32, 128)); progressBar = new JProgressBar(); progressBar.setMinimum(minValue); progressBar.setMaximum(maxValue); progressBar.setStringPainted(true); JButton start = new JButton("Start"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Thread runner = new Thread() { public void run() { counter = minValue; while (counter <= maxValue) { Runnable runme = new Runnable() { public void run() { progressBar.setValue(counter); } }; SwingUtilities.invokeLater(runme); counter++; try { Thread.sleep(100); } catch (Exception ex) { } } } }; runner.start(); } }); getContentPane().add(progressBar, BorderLayout.CENTER); getContentPane().add(start, BorderLayout.WEST); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Main.java
private void hideBlocker() { SwingUtilities.invokeLater(new Runnable() { public void run() { blocker.setVisible(false);/* www .j a va 2s .c o m*/ timer.restart(); } }); }
From source file:io.github.jeddict.collaborate.issues.ExceptionUtils.java
public static void printStackTrace(String errorMessage, final Throwable t, final ModelerFile file) { t.printStackTrace();//ww w. j a va 2 s. c o m if (StringUtils.isBlank(errorMessage)) { errorMessage = t.getMessage(); if (StringUtils.isBlank(errorMessage)) { if (t.getCause() != null && StringUtils.isNotBlank(t.getCause().getMessage())) { errorMessage = t.getCause().getMessage(); } else if (t.getStackTrace().length > 0) { errorMessage = t.getStackTrace()[0].toString(); } } } final String message = errorMessage; LOG.log(Level.ALL, errorMessage, t); String content = file != null ? file.getContent() : ""; SwingUtilities.invokeLater(() -> { ExceptionReporterPanel exceptionReporterPanel = new ExceptionReporterPanel(message, t, content); exceptionReporterPanel.setVisible(true); }); }
From source file:com.mirth.connect.client.ui.editors.ExternalScriptPanel.java
public void updateTable() { if (parent.getSelectedRow() != -1 && !parent.getTableModel() .getValueAt(parent.getSelectedRow(), parent.STEP_TYPE_COL).toString().equals("File")) { SwingUtilities.invokeLater(new Runnable() { public void run() { //parent.getTableModel().setValueAt(variableTextField.getText(), parent.getSelectedRow(), parent.STEP_NAME_COL); parent.updateTaskPane(parent.getTableModel() .getValueAt(parent.getSelectedRow(), parent.STEP_TYPE_COL).toString()); }/*from www. j a v a 2 s . co m*/ }); } }
From source file:meter_rpm.Stackoverflow.java
/** * * @param valinit//from w w w .ja va2 s . c o m * @param title */ public Stackoverflow(int valinit, String title) { //frame.setPreferredSize(new Dimension(300, 300)); frame.add(buildDialPlot(0, 6000, 500)); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle(title); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setVisible(true); } }); }
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
public static void invokeLater(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();/*from w w w .j av a 2 s . co m*/ } else { SwingUtilities.invokeLater(r); } }
From source file:JProgressBarDemo.java
public JProgressBarDemo() { super("JProgressBar Demo"); setSize(300, 100);/*from ww w .ja va2 s .c o m*/ UIManager.put("ProgressBar.selectionBackground", Color.black); UIManager.put("ProgressBar.selectionForeground", Color.white); UIManager.put("ProgressBar.foreground", new Color(8, 32, 128)); progressBar = new JProgressBar(); progressBar.setMinimum(minValue); progressBar.setMaximum(maxValue); progressBar.setStringPainted(true); JButton start = new JButton("Start"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Thread runner = new Thread() { public void run() { counter = minValue; while (counter <= maxValue) { Runnable runme = new Runnable() { public void run() { progressBar.setValue(counter); } }; SwingUtilities.invokeLater(runme); counter++; try { Thread.sleep(100); } catch (Exception ex) { } } } }; runner.start(); } }); getContentPane().add(progressBar, BorderLayout.CENTER); getContentPane().add(start, BorderLayout.WEST); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:gui.accessories.BattleSimFx.java
@Override public void start() { SwingUtilities.invokeLater(new Runnable() { @Override/* w w w .j ava2 s . com*/ public void run() { JFrame frame = new JFrame("Swing JTable"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JApplet applet = new BattleSimFx(); applet.init(); frame.setContentPane(applet.getContentPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); // applet.start(); } }); }