List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:es.emergya.ui.plugins.JButtonCellEditor.java
@Override public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, final int column) { JButton b = (JButton) value; b.setBorderPainted(false);/*from www . j av a2 s . c om*/ b.setContentAreaFilled(false); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { stopCellEditing(); return null; } }; SwingUtilities.invokeLater(sw); SwingWorker<Object, Object> sw1 = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { table.repaint(); return null; } }; SwingUtilities.invokeLater(sw1); } }); return b; }
From source file:edu.cuny.cat.ui.ChargePlotPanel.java
@Override protected synchronized void processDayOpened(final DayOpenedEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { dataset = new DefaultCategoryDataset(); final Specialist activeSpecialists[] = registry.getActiveSpecialists(); for (final Specialist activeSpecialist : activeSpecialists) { dataset.setValue(activeSpecialist.getRegistrationFee(), Account.REGISTRATION_FEE, activeSpecialist.getId()); dataset.setValue(activeSpecialist.getInformationFee(), Account.INFORMATION_FEE, activeSpecialist.getId()); dataset.setValue(activeSpecialist.getShoutFee(), Account.SHOUT_FEE, activeSpecialist.getId()); dataset.setValue(activeSpecialist.getTransactionFee(), Account.TRANSACTION_FEE, activeSpecialist.getId()); dataset.setValue(activeSpecialist.getProfitFee(), Account.PROFIT_FEE, activeSpecialist.getId()); }/*w w w . j a v a 2 s .c o m*/ categoryplot.setDataset(dataset); } }); }
From source file:com.filelocker.gui.Events.java
public void make() { // PrintStream oldOut = System.out; PrintStream printStream = new PrintStream(new OutputStream() { @Override/*from w w w .j a v a 2 s.co m*/ public void write(byte[] buffer, int offset, int length) throws IOException { final String text = new String(buffer, offset, length); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { vNotificationArea.append(text); } }); } @Override public void write(int b) throws IOException { write(new byte[] { (byte) b }, 0, 1); } }); System.setOut(printStream); vPasswordField.setEchoChar('#'); vPasswordLabel.setFont(bigFont); vBrowseLabel.setFont(bigFont); vNotificationArea.setVisible(false); vNotificationArea.setEditable(false); vScroller.setVisible(false); vScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); vScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); vPanel = new JPanel(); vPanel.add(vLockButton); vPanel.add(vCloseButton); vFrame.getContentPane().add(BorderLayout.SOUTH, vPanel); vPanel = new JPanel(); vPanel.add(vPasswordLabel); vPanel.add(vPasswordField); vPanel.add(vBrowseLabel); vPanel.add(vBrowseField); vPanel.add(vBrowseButton); vPanel.add(vScroller); // vPanel.setLayout (new BoxLayout (vPanel, BoxLayout.Y_AXIS)); vFrame.getContentPane().add(BorderLayout.CENTER, vPanel); vLockButton.addActionListener(new vLockButton_Click()); vCloseButton.addActionListener(new vCloseButton_Click()); vBrowseButton.addActionListener(new vBrowseButton_Click()); }
From source file:de.atomfrede.tools.evalutation.util.DialogUtil.java
public void showPlotTypeSelection() { SwingUtilities.invokeLater(new Runnable() { @Override/*www. jav a2s .co m*/ public void run() { Object[] types = PlotType.values(); PlotType selectedType = (PlotType) JOptionPane.showInputDialog(frame, "Select type of plot you want to create.", "Select Plot Type", JOptionPane.QUESTION_MESSAGE, Icons.IC_INFORMATION_LARGE, types, types[0]); if (selectedType != null) { log.debug("Plot " + selectedType + " should be created."); switch (selectedType) { case SIMPLE: { SimplePlotWizard wizard = new SimplePlotWizard(); // wizard.setSize(600, 800); wizard.setSize(wizard.getPreferredSize()); wizard.setLocationRelativeTo(frame); wizard.setModal(true); showWizardDialog(wizard); break; } case TIME: { TimePlotWizard wizard = new TimePlotWizard(); // wizard.setSize(600, 800); wizard.setSize(wizard.getPreferredSize()); wizard.setLocationRelativeTo(frame); wizard.setModal(true); showWizardDialog(wizard); break; } default: break; } } } }); }
From source file:com.android.tools.swing.ui.NavigationComponent.java
public NavigationComponent() { setEditable(false);/*from w ww . j a v a 2 s . c o m*/ setContentType(ContentType.TEXT_HTML.getMimeType()); putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // Disable links decoration. ((HTMLDocument) getDocument()).getStyleSheet().addRule("a { text-decoration:none; }"); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { return; } int idx = Integer.parseInt(e.getDescription()); final T item = myItemStack.get(idx); for (final ItemListener<T> listener : myItemListeners) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { listener.itemSelected(item); } }); } } }); }
From source file:org.jfree.chart.demo.Graphic.java
public ChartPanel get_ChartPanel(int width, int height) { chr = new ChartPanel(chart); chr.setBackground(Color.blue); chr.setBounds(5, 5, width - 5, height - 10); chr.setVisible(true);/*from w ww . ja v a 2 s . c o m*/ chr.setMouseWheelEnabled(true); chr.addChartMouseListener(new ChartMouseListener() { public void chartMouseMoved(ChartMouseEvent chartmouseevent) { } public void chartMouseClicked(ChartMouseEvent chartmouseevent) { SwingUtilities.invokeLater(new Runnable() { public void run() { XYPlot xyplot = (XYPlot) chr.getChart().getPlot(); xyplot.clearAnnotations(); double x, y; x = new BigDecimal(xyplot.getDomainCrosshairValue()).setScale(3, RoundingMode.UP) .doubleValue(); y = new BigDecimal(xyplot.getRangeCrosshairValue()).setScale(3, RoundingMode.UP) .doubleValue(); XYTextAnnotation annotation = new XYTextAnnotation("(" + x + ", " + y + ")", new BigDecimal(x).setScale(3, RoundingMode.UP).doubleValue(), y); annotation.setFont(new Font("serif", Font.BOLD, 15)); annotation.setTextAnchor(TextAnchor.BOTTOM_CENTER); xyplot.addAnnotation(annotation); } }); } }); return chr; }
From source file:de.unidue.inf.is.ezdl.gframedl.EzDL.java
/** * Starts the application.// w w w.java 2s .c om * * @param args * an array of command-line arguments * @param application * the application */ static void start(String[] args, final Application application, final GraphicsConfiguration graphicsConfiguration) { if (!started) { started = true; parseCommandLine(args); URL.setURLStreamHandlerFactory(new InternalProtocolFactory()); initLogging(); if (System.getProperty("collection") != null) { logger.debug("Found Property: " + System.getProperty("collection")); } final Config config = Config.getInstance(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initDesktopSystem(); application.setSessionType(sessionType); SplashScreen splashScreen = new DefaultSplashScreen(application, graphicsConfiguration, sessionType); application.setSplashScreen(splashScreen); boolean autoLogin = config.getUserPropertyAsBoolean("autologin", false); if (!autoLogin) { splashScreen.showSplash(); } else { autoLogin(splashScreen); } } }); } else { throw new IllegalStateException("Already started"); } }
From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotGenerator.java
public SeriesAttributes addSeries(double[][] values, String name, final org.jfree.data.general.SeriesChangeListener stopper) { DefaultXYDataset dataset = (DefaultXYDataset) (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 ScatterPlotSeriesAttributes csa = new ScatterPlotSeriesAttributes(this, name, i, values, stopper); seriesAttributes.add(csa);//from www.j a va 2 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:net.pandoragames.far.ui.swing.component.listener.OperationCallBackListener.java
/** * {@inheritDoc}/*from www.j a va 2 s. c o m*/ */ public void operationTerminated(OperationType type) { for (ComponentContainer comp : endComponents) { if ((comp.type == type) || (comp.type == OperationType.ANY)) { SwingUtilities.invokeLater(new EnDisableComponent(comp.component, comp.endisFlag)); } } }
From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java
public static void createAndShow(final List<File> roots) { final Runnable r = new Runnable() { @Override//w ww .j a va 2 s.c o m public void run() { final JFunkFrame frame = new JFunkFrame(roots); frame.setUpGui(); frame.setVisible(true); frame.tree.requestFocus(); } }; SwingUtilities.invokeLater(r); }