类javax.swing.SwingUtilities源码实例Demo

下面列出了怎么用javax.swing.SwingUtilities的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk8u   文件: SortHeaderMouseAdapter.java
public void mouseClicked(MouseEvent evt) {
    // XXX Benchmark sort performance
    //long start = System.currentTimeMillis();
    CommonUI.setWaitCursor(SwingUtilities.getRoot(table));

    TableColumnModel columnModel = table.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(evt.getX());
    int column = table.convertColumnIndexToModel(viewColumn);
    if (evt.getClickCount() == 1 && column != -1) {
        // Reverse the sorting direction.
        model.sortByColumn(column, !model.isAscending());
    }

    // XXX Benchmark performance
    //      System.out.println("Sort time: " +
    //         (System.currentTimeMillis() - start));
    CommonUI.setDefaultCursor(SwingUtilities.getRoot(table));
}
 
源代码2 项目: jdk8u-jdk   文件: SwingTest.java
private void start() throws Throwable {
    do {
        if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
            run(); // invoke static method on the current thread
        }
        else {
            SwingUtilities.invokeLater(this); // invoke on the event dispatch thread
        }
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof SunToolkit) {
            SunToolkit stk = (SunToolkit) tk;
            stk.realSync(); // wait until done
        }
    }
    while (this.frame != null);
    if (this.error != null) {
        throw this.error;
    }
}
 
源代码3 项目: openjdk-jdk8u   文件: SwingTest.java
private void start() throws Throwable {
    do {
        if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
            run(); // invoke static method on the current thread
        }
        else {
            SwingUtilities.invokeLater(this); // invoke on the event dispatch thread
        }
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof SunToolkit) {
            SunToolkit stk = (SunToolkit) tk;
            stk.realSync(); // wait until done
        }
    }
    while (this.frame != null);
    if (this.error != null) {
        throw this.error;
    }
}
 
@Override
public void dragEnded() {
	if (SwingUtilities.isEventDispatchThread()) {
		plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
		plotConfigurationTree.setBackground(Color.WHITE);
	} else {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
				plotConfigurationTree.setBackground(Color.WHITE);
			}
		});
	}

}
 
源代码5 项目: netbeans   文件: InfoPanel.java
void setBreakpointHits(final DVSupport dvs, final List<DVThread> hits) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            arrowMenu.removeAll();
            threadToMenuItem.clear();
            for (DVThread thread : hits) {
                JMenuItem item = createMenuItem(dvs, thread);
                threadToMenuItem.put(thread, item);
                arrowMenu.add(item);
            }
            if (hits.size() == 0) {
                hideHitsPanel();
            } else {
                setHitsText(hits.size());
                showHitsPanel();
            }
        }
    });
}
 
源代码6 项目: visualvm   文件: SampledTableView.java
public void resetData() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            names = null;
            instances = null;
            bytes = null;
            classNames = null;
            
            renderers[0].setMaxValue(0);
            renderers[1].setMaxValue(0);
            renderers[0].setDiffMode(false);
            renderers[1].setDiffMode(false);

            tableModel.fireTableDataChanged();
        }
    });
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码8 项目: pumpernickel   文件: TextFieldPrompt.java
private void updateBounds() {
	if (SwingUtilities.isEventDispatchThread() == false) {
		SwingUtilities.invokeLater(updateBoundsRunnable);
		return;
	}
	if (adjustingBounds > 0)
		return;

	adjustingBounds++;
	try {
		JTextField parent = (JTextField) getParent();
		if (parent != null)
			setBounds(0, 0, parent.getWidth(), parent.getHeight());
		updateVisibility();
	} finally {
		adjustingBounds--;
	}
}
 
public void restartEarth() {
	localPropertiesService.nullifyChecksumValues();

	try {
		// Re-generate KMZ
		new Thread("Restarting Collect Earth after changing properties/loading project/loading KML points"){
			@Override
			public void run() {
				EarthApp.restart();
			}
		}.start();

		SwingUtilities.invokeLater( ()->{
			JOptionPane.showMessageDialog( callingDialog, Messages.getString("OptionWizard.20"), //$NON-NLS-1$
					Messages.getString("OptionWizard.21"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
			if( callingDialog!= null && callingDialog instanceof PropertiesDialog){
				callingDialog.dispose();
			}
		});

	} catch (final Exception e) {
		logger.error("Error when re-generating the KML code to open in GE ", e); //$NON-NLS-1$
		JOptionPane.showMessageDialog(callingDialog, e.getMessage(), Messages.getString("OptionWizard.23"), //$NON-NLS-1$
				JOptionPane.WARNING_MESSAGE);
	}
}
 
源代码10 项目: netbeans   文件: ETable.java
@Override
public void processKeyEvent(KeyEvent ke) {
    //override the default handling so that
    //the parent will never receive the escape key and
    //close a modal dialog
    if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
        removeSearchField();
        // bugfix #32909, reqest focus when search field is removed
        SwingUtilities.invokeLater(new Runnable() {
            //additional bugfix - do focus change later or removing
            //the component while it's focused will cause focus to
            //get transferred to the next component in the
            //parent focusTraversalPolicy *after* our request
            //focus completes, so focus goes into a black hole - Tim
            @Override
            public void run() {
                ETable.this.requestFocus();
            }
        });
    } else {
        super.processKeyEvent(ke);
    }
}
 
源代码11 项目: dragonwell8_jdk   文件: bug6505523.java
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    Point point = getRowPointToClick(2);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    toolkit.realSync();

}
 
源代码12 项目: netbeans   文件: TagsAndEditorsTest.java
private synchronized void setSortingMode(final PropertySheet ps, final int mode) throws Exception {
    throwMe = null;
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            try {
                ps.setSortingMode(mode);
            } catch (Exception e) {
                throwMe = e;
            }
        }
    });
    if (throwMe != null) {
        Exception ex = throwMe;
        throwMe = null;
        throw (throwMe);
    }
}
 
源代码13 项目: visualvm   文件: ProfilerProgressDisplayer.java
@Override
public ProgressDisplayer showProgress(final String caption, final String message, final ProgressController controller) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (progressLabel == null) initComponents();
            
            DialogDescriptor dd = createDialogDescriptor(caption, message, controller);
            Dialog d = DialogDisplayer.getDefault().createDialog(dd);
            d.pack();

            owner = d;
            if (owner instanceof JDialog) {
                ((JDialog)owner).setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
            }
            
            d.setVisible(true);
        }
    });
    return this;
}
 
源代码14 项目: netbeans   文件: IOExtensionsTest.java
@Override
protected void setUp() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            iowin = IOContainer.getDefault();
            JComponent wnd = LifecycleTest.getIOWindow();
            jf = new JFrame();
            jf.getContentPane().setLayout(new BorderLayout());
            jf.getContentPane().add(wnd, BorderLayout.CENTER);
            jf.setBounds(20, 20, 700, 300);
            jf.setVisible(true);
            io = (NbIO) new NbIOProvider().getIO("Test" + testNum++, false);
            pane = ((OutputTab) iowin.getSelected()).getOutputPane();
        }
    });
}
 
源代码15 项目: dsworkbench   文件: AttackTargetPanel.java
private void fireViewStateChangeEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireViewStateChangeEvent
    if (jToggleButton1.isSelected()) {
        overviewPanel.setOptimalSize();
        jTableScrollPane.setViewportView(overviewPanel);
        jPanel2.remove(overviewPanel);
    } else {
        jTableScrollPane.setViewportView(jVillageTable);
        jPanel2.add(overviewPanel, BorderLayout.CENTER);
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                jPanel2.updateUI();
            }
        });
    }
}
 
源代码16 项目: constellation   文件: ImportFromJdbcPlugin.java
private static void notifyException(final Exception ex) {
    final ByteArrayOutputStream sb = new ByteArrayOutputStream();
    final PrintWriter w = new PrintWriter(sb);
    w.printf("Unexpected exception: %s%n%n", ex.getMessage());
    w.printf("Stack trace:%n%n");
    ex.printStackTrace(w);
    w.flush();
    SwingUtilities.invokeLater(() -> {
        String message;
        try {
            message = sb.toString(StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException ex1) {
            LOGGER.severe(ex1.getLocalizedMessage());
            message = sb.toString();
        }
        final InfoTextPanel itp = new InfoTextPanel(message);
        final NotifyDescriptor d = new NotifyDescriptor.Message(itp, NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
    });
}
 
源代码17 项目: javamelody   文件: MBeansPanel.java
private void expandAll(Container container) {
	for (final Component component : container.getComponents()) {
		if (component instanceof MBeanNodePanel) {
			((MBeanNodePanel) component).expand();
		}
		if (component instanceof Container) {
			expandAll((Container) component);
		}
		if (component instanceof JScrollPane) {
			SwingUtilities.invokeLater(new Runnable() {
				@Override
				public void run() {
					// pour annuler le scrollToVisible des MBeanNodePanel,
					// on repositionne le scrollPane tout en haut
					((JScrollPane) component).getViewport().setViewPosition(new Point(0, 0));
				}
			});
		}
	}
}
 
源代码18 项目: openjdk-jdk9   文件: SelectEditTableCell.java
private static void createUI(final String lookAndFeelString)
        throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            String[][] data = {{"Foo"}};
            String[] cols = {"One"};
            table = new JTable(data, cols);
            table.setSelectionMode(
                    DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            frame = new JFrame(lookAndFeelString);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(table);
            frame.pack();
            frame.setSize(500, frame.getSize().height);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
        }
    });
}
 
源代码19 项目: jdk8u-jdk   文件: XTextAreaPeer.java
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
源代码20 项目: seaglass   文件: SeaGlassTextFieldUI.java
/**
 * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
 */
public void mousePressed(MouseEvent e) {
    if (!SwingUtilities.isLeftMouseButton(e) || !getComponent().isEnabled()) {
        return;
    }

    currentMouseX = e.getX();
    currentMouseY = e.getY();

    if (isOverFindButton()) {
        doFind();
    }

    if (isOverCancelButton()) {
        isCancelArmed = true;
        getComponent().repaint();
    } else if (isCancelArmed) {
        isCancelArmed = false;
        getComponent().repaint();
    }
}
 
源代码21 项目: rscplus   文件: NotificationsHandler.java
/**
 * Sets visibility of the notification window. If this method is called from a thread other than
 * the event dispatch thread, it will invokeLater() to hide the thread the next time the EDT is
 * not busy.
 *
 * @param isVisible Whether the window should be visible
 */
public static void setNotificationWindowVisible(final boolean isVisible) {

  if (SwingUtilities.isEventDispatchThread()) {
    notificationFrame.setVisible(isVisible);
  } else {
    SwingUtilities.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            NotificationsHandler.notificationFrame.setVisible(isVisible);
          }
        });
  }
}
 
源代码22 项目: openjdk-jdk8u   文件: bug8034955.java
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            JFrame frame = new JFrame();
            frame.getContentPane().add(new JLabel("<html>a<title>"));
            frame.pack();
            frame.setVisible(true);
        }
    });
}
 
源代码23 项目: netbeans   文件: OptionsDisplayerImpl.java
public void actionPerformed(ActionEvent e) {
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    log.fine("Options Dialog - Back to modern."); //NOI18N
                    //OptionsDisplayerImpl.this.showOptionsDialog(null);
                    OptionsDisplayer.getDefault().open();
                }
            });
        }
    });
}
 
源代码24 项目: rapidminer-studio   文件: GlobalSearchPanel.java
/**
 * Adds an Action to the actionMap of the necessary steps to be executed for closing the global search results dialog
 *
 * @param actionMap
 * 		the ActionMap that should know how to close the global search results dialog
 */
private void addCloseFullSearchDialogAction(ActionMap actionMap) {
	actionMap.put(CLOSE_FULL_SEARCH_DIALOG, new ResourceAction("") {
		@Override
		public void actionPerformed(ActionEvent e) {
			searchField.requestFocusInWindow();
			SwingUtilities.invokeLater(() -> {
				GlobalSearchPanel.this.hideComponents();
				logGlobalSearchFocusLost();
			});
		}
	});
}
 
源代码25 项目: dragonwell8_jdk   文件: Test6541987.java
private static void start() {
    SwingUtilities.invokeLater(new Test6541987());
    click(KeyEvent.VK_ALT, KeyEvent.VK_H);
    click(KeyEvent.VK_TAB);
    click(KeyEvent.VK_TAB);
    click(KeyEvent.VK_TAB);
    click(KeyEvent.VK_TAB);
}
 
源代码26 项目: libreveris   文件: StepMonitor.java
/**
 * Display a simple message in the progress window.
 *
 * @param msg the message to display
 */
public void notifyMsg (final String msg)
{
    SwingUtilities.invokeLater(
            new Runnable()
    {
        @Override
        public void run ()
        {
            bar.setString(msg);
        }
    });
}
 
public static void main(String... args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new AlphaCompositesApplication().setVisible(true);
        }
    });
}
 
源代码28 项目: visualvm   文件: EnvironmentViewSupport.java
@Override
public void done() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            area.setText(cpuInfo + "<br>" + memInfo + "<br>" + osInfo);
            
            osInfo = null;
            cpuInfo = null;
            memInfo = null;
        }
    });
}
 
源代码29 项目: ramus   文件: ModelsView.java
protected void ch() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Object object = getActiveNode();
            deleteModel.setEnabled(((object instanceof ModelsNode)
                    && (((ModelsNode) object).getChildCount() == 0) && (rules
                    .canDeleteQualifier(((ModelsNode) object)
                            .getQualifier().getId()))));
        }
    });
}
 
源代码30 项目: open-ig   文件: SingleplayerScreen.java
/**
 * Start the load waiter thread.
 * @param barrier the notification barrier
 */
void startLoadWaiter(final Semaphore barrier) {
	loadWaiter = new Thread("Start Game Loading") {
		@Override 
		public void run() {
			try {
				final World world = new World(commons);
				world.definition = selectedDefinition;
				world.difficulty = Difficulty.values()[difficulty];
				
				final Labels labels = new Labels();
				labels.load(commons.rl, U.startWith(selectedDefinition.labels, "labels"));
				world.labels = labels;
				
				world.loadCampaign(commons.rl);
				
				SwingUtilities.invokeLater(new Runnable() {
					@Override
					public void run() {
						commons.labels().replaceWith(labels);
						commons.world(world);
						commons.worldLoading = false;
						commons.nongame = false;
						barrier.release();
					}
				});
			} finally {
				SwingUtilities.invokeLater(new Runnable() {
					@Override
					public void run() {
						loadWaiter = null;	
					}
				});
			}
		}
       };
	loadWaiter.setPriority(Thread.MIN_PRIORITY);
	loadWaiter.start();
}
 
 类所在包
 同包方法