/** * Sets the mute status icon to the status panel. * * @param isMute indicates if the call with this peer is muted */ public void setMute(final boolean isMute) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { setMute(isMute); } }); return; } if (isMute) { muteStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON))); muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); } else { muteStatusLabel.setIcon(null); muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); } // Update input volume control button state to reflect the current // mute status. if (localLevel.isSelected() != isMute) localLevel.setSelected(isMute); this.revalidate(); this.repaint(); }
protected void preCache(List<Position> grid, Position centerPosition) throws InterruptedException { // Pre-cache the tiles that will be needed for the intersection calculations. double n = 0; final long start = System.currentTimeMillis(); for (Position gridPos : grid) // for each grid point. { final double progress = 100 * (n++ / grid.size()); terrain.cacheIntersectingTiles(centerPosition, gridPos); SwingUtilities.invokeLater( new Runnable() { public void run() { progressBar.setValue((int) progress); progressBar.setString(null); } }); } SwingUtilities.invokeLater( new Runnable() { public void run() { progressBar.setValue(100); } }); long end = System.currentTimeMillis(); System.out.printf( "Pre-caching time %d milliseconds, cache usage %f, tiles %d\n", end - start, terrain.getCacheUsage(), terrain.getNumCacheEntries()); }
protected void doUpdateDescription(final Sector sector) { if (sector != null) { try { long size = retrievable.getEstimatedMissingDataSize(sector, 0, cache); final String formattedSize = BulkDownloadPanel.makeSizeDescription(size); SwingUtilities.invokeLater( new Runnable() { public void run() { descriptionLabel.setText(formattedSize); } }); } catch (Exception e) { SwingUtilities.invokeLater( new Runnable() { public void run() { descriptionLabel.setText("-"); } }); } } else SwingUtilities.invokeLater( new Runnable() { public void run() { descriptionLabel.setText("-"); } }); }
private void setApplicationAndMenuButtonIcon(final ResizableIcon icon) { if (System.getProperty("os.name").startsWith("Mac")) { class MacImages { Image icon16; Image icon128; public MacImages(Image icon16, Image icon128) { this.icon16 = icon16; this.icon128 = icon128; } } final Image image16 = getImage(icon, 16); final Image image128 = getImage(icon, 128); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (image16 != null) { setLegacyIconImages(Arrays.asList(image16)); } if (image128 != null) { try { Class appClass = Class.forName("com.apple.eawt.Application"); if (appClass != null) { Object appInstance = appClass.newInstance(); Method setDockImageMethod = appClass.getDeclaredMethod("setDockIconImage", Image.class); if (setDockImageMethod != null) { setDockImageMethod.invoke(appInstance, image128); } } } catch (Throwable t) { t.printStackTrace(); // give up } } setMainAppIcon(icon); } }); } else { final List<Image> images = new ArrayList<Image>(); Image icon16 = getImage(icon, 16); if (icon16 != null) images.add(icon16); Image icon32 = getImage(icon, 32); if (icon32 != null) images.add(icon32); Image icon64 = getImage(icon, 64); if (icon64 != null) images.add(icon64); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (!images.isEmpty()) setLegacyIconImages(images); setMainAppIcon(icon); } }); } }
@Override public void run() { try { // initialize the statusbar status.removeAll(); JProgressBar progress = new JProgressBar(); progress.setMinimum(0); progress.setMaximum((int) f.length()); status.add(progress); status.revalidate(); // try to start reading Reader in = new FileReader(f); char[] buff = new char[4096]; int nch; while ((nch = in.read(buff, 0, buff.length)) != -1) { doc.insertString(doc.getLength(), new String(buff, 0, nch), null); progress.setValue(progress.getValue() + nch); } } catch (IOException e) { final String msg = e.getMessage(); SwingUtilities.invokeLater( new Runnable() { public void run() { JOptionPane.showMessageDialog( getFrame(), "Could not open file: " + msg, "Error opening file", JOptionPane.ERROR_MESSAGE); } }); } catch (BadLocationException e) { System.err.println(e.getMessage()); } doc.addUndoableEditListener(undoHandler); // we are done... get rid of progressbar status.removeAll(); status.revalidate(); resetUndoManager(); if (elementTreePanel != null) { SwingUtilities.invokeLater( new Runnable() { public void run() { elementTreePanel.setEditor(getEditor()); } }); } }
/** * Adds a series, plus a (possibly null) SeriesChangeListener which will receive a <i>single</i> * event if/when the series is deleted from the chart by the user. Returns the series attributes. */ public SeriesAttributes addSeries(Collection objs, String name, SeriesChangeListener stopper) { int i = getSeriesCount(); // need to have added the dataset BEFORE calling this since it'll try to change the name of the // series PieChartSeriesAttributes csa = buildNewAttributes(name, stopper); // set information csa.setElements(new ArrayList(objs)); seriesAttributes.add(csa); revalidate(); // display the new series panel 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; }
/** * Assigns the specified list entries and selects the first entry. * * @param elements result elements * @param srch content search string */ void setElements(final TokenSet elements, final String srch) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { // set new values and selections final int is = elements.size(); final String[] list = new String[is]; for (int i = 0; i < is; i++) list[i] = Token.string(elements.key(i + 1)); if (changed(list)) { // check which old values had been selected final List<String> values = getSelectedValuesList(); final IntList il = new IntList(); for (final String value : values) { final byte[] val = Token.token(value); for (int i = 0; i < is; i++) { if (Token.eq(val, elements.key(i + 1))) { il.add(i); break; } } } setListData(list); setSelectedIndices(il.finish()); } search = srch; } }); }
/** * Sets the output text. * * @param t output text * @param s text size */ public final void setText(final byte[] t, final int s) { // remove invalid characters and compare old with new string int ns = 0; final int ts = text.size(); final byte[] tt = text.text(); boolean eq = true; for (int r = 0; r < s; ++r) { final byte b = t[r]; // support characters, highlighting codes, tabs and newlines if (b >= ' ' || b <= TokenBuilder.MARK || b == 0x09 || b == 0x0A) { t[ns++] = t[r]; } eq &= ns < ts && ns < s && t[ns] == tt[ns]; } eq &= ns == ts; // new text is different... if (!eq) { text = new BaseXTextTokens(Arrays.copyOf(t, ns)); rend.setText(text); scroll.pos(0); } if (undo != null) undo.store(t.length != ns ? Arrays.copyOf(t, ns) : t, 0); SwingUtilities.invokeLater(calc); }
public Dimension requestResize( final Dimension newSize, final RequestOrigin origin, int cursorY, JediTerminal.ResizeHandler resizeHandler) { if (!newSize.equals(myTermSize)) { myTerminalTextBuffer.lock(); try { myTerminalTextBuffer.resize(newSize, origin, cursorY, resizeHandler, mySelection); myTermSize = (Dimension) newSize.clone(); final Dimension pixelDimension = new Dimension(getPixelWidth(), getPixelHeight()); setPreferredSize(pixelDimension); if (myTerminalPanelListener != null) { myTerminalPanelListener.onPanelResize(pixelDimension, origin); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { updateScrolling(); } }); } finally { myTerminalTextBuffer.unlock(); } } return new Dimension(getPixelWidth(), getPixelHeight()); }
@Override public void enter() { controlMenu(); // pns^ 入ってきたら,キーワードフィールドにフォーカス // view.getKeywordFld().requestFocusInWindow(); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { view.getKeywordFld().requestFocusInWindow(); view.getKeywordFld().selectAll(); } }); // pns$ // s.oh^ 2014/08/19 ID権限 if (Project.isOtherCare()) { String text = Project.getString("patient.search.text", ""); if (text != null && !text.isEmpty()) { view.getKeywordFld().setText(text); find(view.getKeywordFld().getText()); } else { view.getKeywordFld().setText("設定なし"); } view.getSortItem().setEnabled(false); view.getKeywordFld().setEnabled(false); view.getTmpKarteButton().setEnabled(false); } // s.oh$ }
protected void computeAndShowIntersections(final Position curPos) { this.previousCurrentPosition = curPos; SwingUtilities.invokeLater( new Runnable() { public void run() { setCursor(WaitCursor); } }); // Dispatch the calculation threads in a separate thread to avoid locking up the user // interface. this.calculationDispatchThread = new Thread( new Runnable() { public void run() { try { performIntersectionTests(curPos); } catch (InterruptedException e) { System.out.println("Operation was interrupted"); } } }); this.calculationDispatchThread.start(); }
public void focusLost(final FocusEvent e) { if (myPanel.getProject().isDisposed()) { myPanel.setContextComponent(null); myPanel.hideHint(); return; } final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent()); shouldFocusEditor = dialog != null; if (dialog != null) { Disposer.register( dialog.getDisposable(), new Disposable() { @Override public void dispose() { if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) { shouldFocusEditor = false; } } }); } // required invokeLater since in current call sequence KeyboardFocusManager is not initialized // yet // but future focused component //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { processFocusLost(e); } }); }
/** * Details have been retrieved. * * @param details the details retrieved if any. */ public void detailsRetrieved(Iterator<GenericDetail> details) { // if treenode has changed ignore if (!source.equals(treeNode)) return; while (details.hasNext()) { GenericDetail d = details.next(); if (d instanceof PhoneNumberDetail && !(d instanceof PagerDetail) && !(d instanceof FaxDetail)) { final PhoneNumberDetail pnd = (PhoneNumberDetail) d; if (pnd.getNumber() != null && pnd.getNumber().length() > 0) { SwingUtilities.invokeLater( new Runnable() { public void run() { callButton.setEnabled(true); if (pnd instanceof VideoDetail) { callVideoButton.setEnabled(true); desktopSharingButton.setEnabled(true); } treeContactList.refreshContact(uiContact); } }); return; } } } }
public static void main(String[] args) { /* Use an appropriate Look and Feel */ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InstantiationException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } /* Turn off metal's use of bold fonts */ UIManager.put("swing.boldMetal", Boolean.FALSE); // Schedule a job for the event-dispatching thread: // adding TrayIcon. SwingUtilities.invokeLater( new Runnable() { public void run() { weather = new Wetter(); createAndShowGUI(); } }); }
public void refreshRobotList(final boolean withClear) { final Runnable runnable = new Runnable() { public void run() { final IWindowManager windowManager = Container.getComponent(IWindowManager.class); try { windowManager.setBusyPointer(true); repositoryManager.refresh(withClear); List<IRobotSpecItem> robotList = repositoryManager.getRepositoryItems( onlyShowSource, onlyShowWithPackage, onlyShowRobots, onlyShowDevelopment, false, ignoreTeamRobots, onlyShowInJar); getAvailableRobotsPanel().setRobotList(robotList); if (preSelectedRobots != null && preSelectedRobots.length() > 0) { setSelectedRobots(preSelectedRobots); preSelectedRobots = null; } } finally { windowManager.setBusyPointer(false); } } }; SwingUtilities.invokeLater(runnable); }
@Override public void keyPressed(final KeyEvent e) { if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) { if (!Character.isLetter(e.getKeyChar())) { return; } final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject()); final ActionCallback firstCharTyped = new ActionCallback(); focusManager.typeAheadUntil(firstCharTyped); myPanel.moveDown(); //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { try { final Robot robot = new Robot(); final boolean shiftOn = e.isShiftDown(); final int code = e.getKeyCode(); if (shiftOn) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(code); robot.keyRelease(code); // don't release Shift firstCharTyped.setDone(); } catch (AWTException ignored) { } } }); } }
public static void main(String[] args) { try { // non-throwing message printer Kdu_sysout_message sysout = new Kdu_sysout_message(false); // exception-throwing message printer Kdu_sysout_message syserr = new Kdu_sysout_message(true); // non-throwing formatted printer Kdu_message_formatter formattedSysout = new Kdu_message_formatter(sysout); // throwing formatted printer Kdu_message_formatter formattedSyserr = new Kdu_message_formatter(syserr); Kdu_global.Kdu_customize_warnings(formattedSysout); Kdu_global.Kdu_customize_errors(formattedSyserr); } catch (KduException e) { System.err.printf("Exception during Kdu stream tie: %s\n", e.getMessage()); } if (args.length != 1) { System.err.println("You must supply a filename (JP2, JPX or raw code-stream)"); System.exit(0); } final String filename = args[0]; SwingUtilities.invokeLater( new Runnable() { public void run() { Haikdu app = new Haikdu(filename); } }); }
private void setDataInternal( SmartPsiElementPointer element, String text, final Rectangle viewRect, boolean skip) { boolean justShown = false; myElement = element; if (!myIsShown && myHint != null) { myEditorPane.setText(text); applyFontSize(); myManager.showHint(myHint); myIsShown = justShown = true; } if (!justShown) { myEditorPane.setText(text); applyFontSize(); } if (!skip) { myText = text; } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { myEditorPane.scrollRectToVisible(viewRect); } }); }
private void updateTextArea(final String text) { SwingUtilities.invokeLater( new Runnable() { public void run() { jTextArea.append(text); } }); }
public static void main(String[] args) { SwingUtilities.invokeLater( new Runnable() { public void run() { go(); } }); }
public static void main(String[] args) { SwingUtilities.invokeLater( new Runnable() { public void run() { new MainWindow().setVisible(true); } }); }
public static void setStepText(final int step, final String text) { SwingUtilities.invokeLater( new Runnable() { public void run() { _stepLabels[step].setText(text); } }); }
public static void main(String args[]) { SwingUtilities.invokeLater( new Runnable() { public void run() { new IGEgui().setVisible(true); } }); }
public static void main(String args[]) { SwingUtilities.invokeLater( new Runnable() { public void run() { new Project2(); } }); }
private void showErrorPanel() { SwingUtilities.invokeLater( new Runnable() { public void run() { ApplicationManager.getCurrentApplicationInstance().setGlassPanelContents(errorPanel); } }); }
private void repaintLater() { SwingUtilities.invokeLater( new Runnable() { public void run() { SIPCommTextButton.this.repaint(); } }); }
private void setScore() { SwingUtilities.invokeLater( new Runnable() { public void run() { setText(Integer.toString(score)); } }); }
public void itemStateChanged(ItemEvent e) { SwingUtilities.invokeLater( new Runnable() { public void run() { enableDisableButton(); } }); }
public static void main(String[] args) throws Exception { SwingUtilities.invokeLater( new Runnable() { public void run() { new LockableDemo().setVisible(true); } }); }
private void repaintLater() { SwingUtilities.invokeLater( new Runnable() { public void run() { FramedImageWithMenu.this.repaint(); } }); }