List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:com.przemo.probabilities.gui.SimulatorPanel.java
protected void simulationStepForAccountTaken() { if (chartData != null && !chartData.isEmpty()) { SwingUtilities.invokeLater(() -> { if (chartData.get(chartData.size() - 1) <= 0) { lblBankrupt.setVisible(true); }// w w w . ja va 2 s. c o m this.iterationLab.setText(String.valueOf(chartData.size())); if (p != null) { p.getChart().getCategoryPlot().setDataset(buildChartData()); } }); } }
From source file:com.haulmont.cuba.desktop.LoginDialog.java
protected Container createContentPane() { MigLayout layout = new MigLayout("fillx, insets dialog", "[right][]"); JPanel panel = new JPanel(layout); panel.add(new JLabel(messages.getMainMessage("loginWindow.loginField", resolvedLocale))); nameField = new JTextField(); passwordField = new JPasswordField(); String defaultName = desktopConfig.getLoginDialogDefaultUser(); String lastLogin = loginProperties.loadLastLogin(); if (!StringUtils.isBlank(lastLogin)) { nameField.setText(lastLogin);/*from ww w . j a va 2 s . co m*/ SwingUtilities.invokeLater(() -> passwordField.requestFocus()); } else if (!StringUtils.isBlank(defaultName)) { nameField.setText(defaultName); } panel.add(nameField, "width 150!, wrap"); panel.add(new JLabel(messages.getMainMessage("loginWindow.passwordField", resolvedLocale))); String defaultPassword = desktopConfig.getLoginDialogDefaultPassword(); if (!StringUtils.isBlank(defaultPassword)) passwordField.setText(defaultPassword); panel.add(passwordField, "width 150!, wrap"); Configuration configuration = AppBeans.get(Configuration.NAME); localeCombo = new JComboBox<>(); initLocales(localeCombo); if (configuration.getConfig(GlobalConfig.class).getLocaleSelectVisible()) { panel.add(new JLabel(messages.getMainMessage("loginWindow.localesSelect", resolvedLocale))); panel.add(localeCombo, "width 150!, wrap"); } loginBtn = new JButton(messages.getMainMessage("loginWindow.okButton", resolvedLocale)); loginBtn.setIcon(App.getInstance().getResources().getIcon("icons/ok.png")); loginBtn.addActionListener(e -> doLogin()); DesktopComponentsHelper.adjustSize(loginBtn); panel.add(loginBtn, "span, align center"); getRootPane().setDefaultButton(loginBtn); assignTestIdsIfNeeded(panel); return panel; }
From source file:ch.zhaw.iamp.rct.Controller.java
/** * Shows the {@link MainWindow}. If there is no instance yet, one will be * created.//from ww w. j ava2 s.c o m */ public void showMainWindow() { configureGuiToolkit(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { mainWindow = new MainWindow(); Components.setIcons(mainWindow); mainWindow.setController(App.controller); mainWindow.setVisible(true); } }); }
From source file:joinery.impl.Display.java
public static <V> void plot(final DataFrame<V> df, final PlotType type) { SwingUtilities.invokeLater(new Runnable() { @Override/* w ww. ja v a 2s. c o m*/ public void run() { final JFrame frame = draw(df, new JFrame(title(df)), type); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java
protected void requestRepaint() { if (!scheduledRepaint) { SwingUtilities.invokeLater(new Runnable() { @Override// ww w .j av a 2 s .c o m public void run() { JComponent view = DesktopComponentsHelper.getComposition(content); view.revalidate(); view.repaint(); scheduledRepaint = false; } }); scheduledRepaint = true; } }
From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java
public SeriesAttributes addSeries(double[][] values, String name, final org.jfree.data.general.SeriesChangeListener stopper) { DefaultXYZDataset dataset = (DefaultXYZDataset) (getSeriesDataset()); int i = dataset.getSeriesCount(); dataset.addSeries(new UniqueString(name), values); // need to have added the dataset BEFORE calling this since it'll try to change the name of the series BubbleChartSeriesAttributes csa = new BubbleChartSeriesAttributes(this, name, i, values, stopper); seriesAttributes.add(csa, name);//from w w w.j a v a2 s.c o m revalidate(); update(); // won't update properly unless I force it here by letting all the existing scheduled events to go through. Dumb design. :-( SwingUtilities.invokeLater(new Runnable() { public void run() { update(); } }); return csa; }
From source file:com.mirth.connect.client.ui.editors.MessageBuilder.java
public void updateTable() { if (parent.getSelectedRow() != -1 && !parent.getTableModel() .getValueAt(parent.getSelectedRow(), parent.STEP_TYPE_COL).toString().equals("JavaScript")) { 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 ww w. j a v a2s. c o m }); } }
From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java
public void updateValue(final double value) { SwingUtilities.invokeLater(new Runnable() { public void run() { current.setValue(value);//from w w w. j a v a2 s . c om } }); updateMinMax(value); }
From source file:ProgressDialog.java
private void setupEventHandlers() { addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent event) { final Thread task = new Thread(runnable); task.start();//from www.java 2s . co m new Thread() { public void run() { try { task.join(); } catch (InterruptedException e) { } SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(false); } }); } }.start(); } }); }
From source file:edu.ku.brc.specify.toycode.FixSQLString.java
/** * // w w w .j a v a 2 s .c o m */ private void fixFromtextToSQL() { String srcStr = srcTA.getText(); srcStr = StringUtils.replace(srcStr, "\"", ""); srcStr = StringUtils.replace(srcStr, "+", ""); srcStr = StringUtils.replace(srcStr, ";", ""); dstTA.setText(srcStr); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dstTA.requestFocus(); dstTA.selectAll(); UIHelper.setTextToClipboard(dstTA.getText()); } }); }