本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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.
}
}
}
示例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);
}
示例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);
}
示例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.
}
}
}
示例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();
}
};
}
示例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(); }
};
}