当前位置: 首页>>代码示例>>Java>>正文


Java SwingUtilities类代码示例

本文整理汇总了Java中javax.swing.SwingUtilities的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities类的具体用法?Java SwingUtilities怎么用?Java SwingUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SwingUtilities类属于javax.swing包,在下文中一共展示了SwingUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    createUI();
    Robot robot = new Robot();
    robot.waitForIdle();
    Rectangle rect = window.getBounds();
    rect.x += rect.width - 10;
    rect.y += rect.height - 10;
    robot.delay(1000);
    Color c = robot.getPixelColor(rect.x, rect.y);
    try {
        if (!c.equals(Color.RED)) {
            throw new RuntimeException("Test Failed");
        }
    } finally {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                background.dispose();
                window.dispose();
            }
        });
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:SetShapeTest.java

示例2: postProcessKeyEvent

import javax.swing.SwingUtilities; //导入依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
    if (ev.isConsumed())
        return false;

    if (processShortcut(ev))
        return true;

    Window w = SwingUtilities.windowForComponent(ev.getComponent());        
    if (w instanceof Dialog && !WindowManagerImpl.isSeparateWindow(w))
        return false;
    
    JFrame mw = (JFrame)WindowManagerImpl.getInstance().getMainWindow();
    if (w == mw) {
        return false;
    }

    JMenuBar mb = mw.getJMenuBar();
    if (mb == null)
        return false;
    boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);        
    boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
    
    if (res)
        ev.consume();
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ShortcutAndMenuKeyEventProcessor.java

示例3: tMacrosTableChanged

import javax.swing.SwingUtilities; //导入依赖的package包/类
private void tMacrosTableChanged(final TableModelEvent evt) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (evt.getType() == TableModelEvent.INSERT) {
                tMacros.getSelectionModel().setSelectionInterval(evt.getFirstRow(), evt.getFirstRow());
            } else if (evt.getType() == TableModelEvent.DELETE) {
                // try the next row after the deleted one
                int tableRow = evt.getLastRow();
                if (tableRow < tMacros.getModel().getRowCount()) {
                    tMacros.getSelectionModel().setSelectionInterval(tableRow, tableRow);
                } else {
                    // try the previous row
                    tableRow = evt.getFirstRow() - 1;
                    if (tableRow >= 0) {
                        tMacros.getSelectionModel().setSelectionInterval(tableRow, tableRow);
                    } else {
                        tMacros.getSelectionModel().clearSelection();
                    }
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MacrosPanel.java

示例4: selectAndExpandProject

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void selectAndExpandProject( final Project p ) {
    if( p == null) return;
    
    // invoke later to select the being opened project if the focus is outside ProjectTab
    SwingUtilities.invokeLater(new Runnable() {
        
        final ExplorerManager.Provider ptLogial = findDefault(ProjectTab_ID_LOGICAL);
        
        public void run() {
            Node root = ptLogial.getExplorerManager().getRootContext();
            // Node projNode = root.getChildren ().findChild( p.getProjectDirectory().getName () );
            Node projNode = root.getChildren().findChild( ProjectUtils.getInformation( p ).getName() );
            if ( projNode != null ) {
                try {
                    ptLogial.getExplorerManager().setSelectedNodes( new Node[] { projNode } );
                } catch (Exception ignore) {
                    // may ignore it
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:HgProjectUtils.java

示例5: main

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    CountDownLatch go = new CountDownLatch(1);
    Robot r = new Robot();
    SwingUtilities.invokeLater(() -> System.out.println("some work"));
    Thread t = new Thread(() -> {
        synchronized (WAIT_LOCK) {
            go.countDown();
            try {
                Thread.sleep(30000);
                passed = false;
            } catch (InterruptedException e) {
                System.out.println("e = " + e);
            }
        }
    });
    t.start();
    go.await();
    r.waitForIdle();
    t.interrupt();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:WaitForIdleSyncroizedOnString.java

示例6: init

import javax.swing.SwingUtilities; //导入依赖的package包/类
void init() {
    isInitialized = true;
    
    fileListModel.clear();
    fileList.setEnabled(!isInitialized);
    
    if (isInitialized) {
        PROCESSOR.post(new Runnable() {
            public void run() {
                SessionStorage _storage = getStorage();
                final Collection<FileObject> files = getFiles(_storage);
                
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        fileList.setEnabled(true);
                        for (FileObject fo : files) fileListModel.addElement(fo);
                    }
                });
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ClassMethodSelector.java

示例7: startProgress

import javax.swing.SwingUtilities; //导入依赖的package包/类
public void startProgress() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ProgressHandle progress = getProgressHandle(); // NOI18N
            JComponent bar = ProgressHandleFactory.createProgressComponent(progress);
            stopButton = new JButton(org.openide.util.NbBundle.getMessage(RepositoryStep.class, "BK2022")); // NOI18N
            stopButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancel();
                }
            });
            progressComponent = new JPanel();
            progressComponent.setLayout(new BorderLayout(6, 0));
            progressLabel = new JLabel();
            progressLabel.setText(getDisplayName());
            progressComponent.add(progressLabel, BorderLayout.NORTH);
            progressComponent.add(bar, BorderLayout.CENTER);
            progressComponent.add(stopButton, BorderLayout.LINE_END);
            WizardStepProgressSupport.super.startProgress();
            panel.setVisible(true);
            panel.add(progressComponent);
            panel.revalidate();
        }
    });                                                
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:WizardStepProgressSupport.java

示例8: executeTest

import javax.swing.SwingUtilities; //导入依赖的package包/类
private static void executeTest() throws Exception {

        Point point = Util.getCenterPoint(menu);
        performMouseOperations(point);
        point = Util.getCenterPoint(menuItem);
        performMouseOperations(point);
        point = Util.getCenterPoint(menu);
        performMouseOperations(point);
        point = Util.getCenterPoint(menuItem);
        performMouseOperations(point);
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                internalFrame = desktopPane.getSelectedFrame();
                internalFrame.doDefaultCloseAction();
                internalFrame = desktopPane.getSelectedFrame();
            }
        });

        robot.delay(2000);
        if (internalFrame == null) {
            dispose();
            throw new RuntimeException("Test Failed");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TestJInternalFrameDispose.java

示例9: main

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Create Robot
    testRobot = new Robot();

    // Create test UI
    String lookAndFeelString = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try {
                constructTestUI(lookAndFeelString);
            } catch (Exception ex) {
                throw new RuntimeException("Exception creating test UI");
            }
        }
    });

    testRobot.waitForIdle();
    testRobot.delay(200);

    // Run test method
    testScrollBarThumbPainter();

    // Dispose test UI
    disposeTestUI();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SynthScrollbarThumbPainterTest.java

示例10: main

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);

    test = new TestUI(latch);
    SwingUtilities.invokeAndWait(() -> {
        try {
            test.createUI();
        } catch (Exception ex) {
            throw new RuntimeException("Exception while creating UI");
        }
    });

    boolean status = latch.await(2, TimeUnit.MINUTES);
    if (!status) {
        System.out.println("Test timed out.");
    }

    if (test.testResult == false) {
        disposeUI();
        throw new RuntimeException("Test Failed.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TestDisabledToolTipBorder.java

示例11: doZoom

import javax.swing.SwingUtilities; //导入依赖的package包/类
public void doZoom(Point2D p, double factor) {
	LatLon dest = new LatLon(Angle.fromDegrees(p.getY()), Angle.fromDegrees(p.getX()));
	double wwzoom = 2785 * Math.pow(factor, -.8311) * 10000;

	final OrbitView view = (OrbitView) wwd.getView();

	FlyToOrbitViewAnimator fto = 
		FlyToOrbitViewAnimator.createFlyToOrbitViewAnimator(
			view,
			view.getCenterPosition(), new Position(dest, 0),
			view.getHeading(), Angle.fromDegrees(0),
			view.getPitch(), Angle.fromDegrees(0),
			view.getZoom(), wwzoom,
			5000, WorldWind.CONSTANT); //was true

	view.addAnimator(fto);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			((MapApp)getApp()).getFrame().toFront();
			view.firePropertyChange(AVKey.VIEW,  null, view);
		}
	});
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:25,代码来源:WWMap.java

示例12: main

import javax.swing.SwingUtilities; //导入依赖的package包/类
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
            } catch (Exception e) {}
            
            JFrame frame = new JFrame("JavaFX 2.0 in Swing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JApplet applet = new SwingInterop();
            applet.init();

            frame.setContentPane(applet.getContentPane());

            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);

            applet.start();
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:SwingInterop.java

示例13: update

import javax.swing.SwingUtilities; //导入依赖的package包/类
/** called when Observable changes (pot changes) */
@Override
public void update(final Observable observable, final Object obj) {
	if (observable instanceof IPot) {
		// log.info("observable="+observable);
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				// don't do the following - it sometimes prevents display updates or results in double updates
				// slider.setValueIsAdjusting(true); // try to prevent a new event from the slider
				updateAppearance();
			}
		});
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:SimpleIPotSliderTextControl.java

示例14: buildSpecificFields

import javax.swing.SwingUtilities; //导入依赖的package包/类
/**
 * Builds the specific fields for the selected input method
 */
private synchronized void buildSpecificFields() {
    SwingUtilities.invokeLater(() -> {
        if (findId("editor") != null) {
            remove((java.awt.Component) findId("editor"));
        }
        Component editor = null;
        if (input == null) {
            editor = Panels.create();
        } else {
            if (input instanceof MultiFileInput) {
                editor = buildMultiFile();
            }
            if (input instanceof WebcamInput) {
                editor = Panels.create();
            }
        }
        put(editor.id("editor"));
        revalidate();
    });
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:24,代码来源:InputEditor.java

示例15: actionPerformed

import javax.swing.SwingUtilities; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  Runnable runner = new Runnable() {
    @Override
    public void run() {
      TreePath[] paths = resourcesTree.getSelectionPaths();
      for(TreePath path : paths) {
        final Object value = ((DefaultMutableTreeNode)
          path.getLastPathComponent()).getUserObject();
        if(value instanceof Handle) {
          SwingUtilities.invokeLater(new Runnable() { @Override
          public void run() {
            new CloseViewAction((Handle)value).actionPerformed(null);
          }});
        }
      }
    }
  };
  Thread thread = new Thread(runner,
    "CloseViewsForSelectedResourcesAction");
  thread.setPriority(Thread.MIN_PRIORITY);
  thread.start();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:MainFrame.java


注:本文中的javax.swing.SwingUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。