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


Java Window.dispose方法代码示例

本文整理汇总了Java中java.awt.Window.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Window.dispose方法的具体用法?Java Window.dispose怎么用?Java Window.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Window的用法示例。


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

示例1: test

import java.awt.Window; //导入方法依赖的package包/类
private static void test(GraphicsConfiguration gc) throws AWTException {
    final Window frame = new Frame(gc);
    try {
        frame.addMouseWheelListener(e -> {
            wheelX = e.getXOnScreen();
            wheelY = e.getYOnScreen();
            done = true;
        });
        frame.setSize(300, 300);
        frame.setVisible(true);

        final Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.setAutoWaitForIdle(true);
        mouseX = frame.getX() + frame.getWidth() / 2;
        mouseY = frame.getY() + frame.getHeight() / 2;

        robot.mouseMove(mouseX, mouseY);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseWheel(10);

        validate();
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MouseWheelAbsXY.java

示例2: main

import java.awt.Window; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    sleep();
    window.setBackground(Color.GREEN);
    sleep();
    final Robot robot = new Robot();
    robot.setAutoDelay(200);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:BackgroundIsNotUpdated.java

示例3: main

import java.awt.Window; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final boolean dump = Boolean.parseBoolean(args[0]);
    final Window w = new Frame() {
        @Override
        public void list(final PrintStream out, final int indent) {
            super.list(out, indent);
            dumped = true;
        }
    };
    w.setSize(200, 200);
    w.setLocationRelativeTo(null);
    w.setVisible(true);

    final Robot robot = new Robot();
    robot.setAutoDelay(50);
    robot.setAutoWaitForIdle(true);
    robot.mouseMove(w.getX() + w.getWidth() / 2,
                    w.getY() + w.getHeight() / 2);
    robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_SHIFT);
    robot.keyPress(KeyEvent.VK_F1);
    robot.keyRelease(KeyEvent.VK_F1);
    robot.keyRelease(KeyEvent.VK_SHIFT);
    robot.keyRelease(KeyEvent.VK_CONTROL);

    w.dispose();
    if (dumped != dump) {
        throw new RuntimeException("Exp:" + dump + ", actual:" + dumped);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:DumpOnKey.java

示例4: main

import java.awt.Window; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final GraphicsEnvironment lge = getLocalGraphicsEnvironment();
    final GraphicsDevice dev = lge.getDefaultScreenDevice();
    final GraphicsConfiguration config = dev.getDefaultConfiguration();

    test(config.createCompatibleImage(10, 10).getGraphics());
    test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics());
    test(config.createCompatibleImage(10, 10, BITMASK).getGraphics());
    test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics());

    test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics());

    final Window frame = new Frame();
    frame.pack();
    try {
        test(frame.getGraphics());
        test(frame.createImage(10, 10).getGraphics());
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SurfaceDestination.java

示例5: testMouseInfoPeer

import java.awt.Window; //导入方法依赖的package包/类
private static void testMouseInfoPeer() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        ComponentFactory componentFactory = (ComponentFactory) toolkit;

        MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
        mouseInfoPeer.fillPointWithCoords(new Point());

        Window win = new Window(null);
        win.setSize(300, 300);
        win.setVisible(true);

        mouseInfoPeer.isWindowUnderMouse(win);
        win.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PointerInfoCrashTest.java

示例6: btnCloseActionPerformed

import java.awt.Window; //导入方法依赖的package包/类
private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
    Window w = (Window) SwingUtilities.getAncestorOfClass(
            Window.class, this);
    if (w != null) {
        w.dispose();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:IgnoreListPanel.java

示例7: actionPerformed

import java.awt.Window; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ev) {
    JComponent c = (JComponent)ev.getSource();
    Window w = SwingUtilities.windowForComponent(c);
    if (w != null) {
        w.dispose();
    } 
    Installer.RP.post(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:UIHandler.java

示例8: closeDialog

import java.awt.Window; //导入方法依赖的package包/类
private void closeDialog() {
    //save dialog size on closing via dialog buttons
    getDefault().previousDialogSize=this.getSize();

    Window w = SwingUtilities.getWindowAncestor(this);
    w.setVisible(false);
    w.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DocumentsDlg.java

示例9: exit

import java.awt.Window; //导入方法依赖的package包/类
/**
 * This method has to be called each time a JMT application is terminated. If all applications
 * are terminated, JVM is killed.
 * @param application application to be terminated. If application was not disposed,
 * this method will do 'dispose()' too.
 */
public static void exit(Window application) {
	// Disposes application window if user did not do it.
	if (application.isDisplayable()) {
		application.dispose();
	}
	windows.remove(application);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:14,代码来源:JWatWorkloadManager.java

示例10: exit

import java.awt.Window; //导入方法依赖的package包/类
/**
 * This method has to be called each time a JMT application is terminated. If all applications
 * are terminated, JVM is killed.
 * @param application application to be terminated. If application was not disposed,
 * this method will do 'dispose()' too.
 */
public static void exit(Window application) {
	synchronized (windows) {
		// Disposes application window if user did not do it.
		if (application.isDisplayable()) {
			application.dispose();
		}
		windows.remove(application);
		if (windows.isEmpty()) {
	//		System.exit(0); // Closes current JVM with no error code.
		}
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:19,代码来源:Manager.java

示例11: removeFrom

import java.awt.Window; //导入方法依赖的package包/类
public void removeFrom(Buildable b) {
  GameModule.getGameModule().getGameState().removeGameComponent(this);
  Window w = SwingUtilities.getWindowAncestor(theMap);
  if (w != null) {
    w.dispose();
  }
  GameModule.getGameModule().getToolBar().remove(launchButton);
  idMgr.remove(this);
  if (picker != null) {
    GameModule.getGameModule().removeCommandEncoder(picker);
    GameModule.getGameModule().getGameState().addGameComponent(picker);
  }
  PlayerRoster.removeSideChangeListener(this);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:15,代码来源:Map.java

示例12: exit

import java.awt.Window; //导入方法依赖的package包/类
/**
 * This method has to be called each time a JMT application is terminated. If all applications
 * are terminated, JVM is killed.
 * @param application application to be terminated. If application was not disposed,
 * this method will do 'dispose()' too.
 */
public static void exit(Window application) {
	// Disposes application window if user didn't do it.
	if (application.isDisplayable()) {
		application.dispose();
	}
	windows.remove(application);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:14,代码来源:JWatWorkloadManager.java

示例13: exit

import java.awt.Window; //导入方法依赖的package包/类
/**
 * This method has to be called each time a JMT application is terminated. If all applications
 * are terminated, JVM is killed.
 * @param application application to be terminated. If application was not disposed,
 * this method will do 'dispose()' too.
 */
public static void exit(Window application) {
	synchronized (windows) {
		// Disposes application window if user didn't do it.
		if (application.isDisplayable()) {
			application.dispose();
		}
		windows.remove(application);
		if (windows.isEmpty()) {
			System.exit(0); // Closes current JVM with no error code.
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:Manager.java

示例14: createDispose

import java.awt.Window; //导入方法依赖的package包/类
/**
 * This helper method returns a Runnable whose run() method will call
 * window.dispose()
 */
public static final Runner createDispose(final Window window) {
	return new Runner() {
		private static final long serialVersionUID = 0;

		public final void run() {
			window.dispose();
		}

		public final void run(Object arg) {
			window.dispose();
		}
	};
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:Runner.java

示例15: createDispose

import java.awt.Window; //导入方法依赖的package包/类
/** This helper method returns a Runnable whose run() method will call window.dispose() */
public static final Runner createDispose(final Window window) {
   return new Runner() {
      private static final long serialVersionUID = 0;
      public final void run()           { window.dispose(); }
      public final void run(Object arg) { window.dispose(); }
   };
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:9,代码来源:Runner.java


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