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


Java JFrame.dispose方法代码示例

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


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

示例1: drawAndSave

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void drawAndSave(JPanel graphDrawing, String fileName) {
    JFrame frame = new JFrame("Drawing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(graphDrawing);
    frame.setSize(500, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    exportToImage("jpg", graphDrawing, fileName);
    frame.dispose();
}
 
开发者ID:tslaats,项目名称:SE2017-Team1,代码行数:11,代码来源:TestUtil.java

示例2: testNewObjectPanelTest

import javax.swing.JFrame; //导入方法依赖的package包/类
public void testNewObjectPanelTest() {
    NewObjectPanel panel = new NewObjectPanel();
    JFrame frame = new JFrame("sss");
    
    frame.getContentPane().add(panel, java.awt.BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
    assertNotNull(panel.getNewObjectName());
    assertNotNull(panel.getPreferredSize());
    MyChangeListener list = new MyChangeListener();
    panel.addChangeListener(list);
    panel.removeChangeListener(list);
    panel.addNotify();
    assertNotNull(panel.defaultNewObjectName());
    frame.dispose();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:NewObjectPanelTest.java

示例3: showPasswordDialog

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Show password dialog if enabled
 */
private String showPasswordDialog() {
	JPanel panel = new JPanel(new BorderLayout());
	JPasswordField pf = new JPasswordField();
	panel.setBorder(new EmptyBorder(0, 10, 0, 10));
	panel.add(pf, BorderLayout.NORTH);
	JFrame frame = new JFrame();
	frame.setAlwaysOnTop(true);
	pf.requestFocus();

	int option = JOptionPane.showConfirmDialog(frame, panel, I18n.get("main.start.sharelinkpwd"),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
	frame.dispose();
	if (option == JOptionPane.OK_OPTION) {
		return new String(pf.getPassword());
	} else {
		return null;
	}
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:22,代码来源:Dropzone.java

示例4: remove

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * If the component is not shown on a tab but in a separate frame,
 * disposes the frame.
 */
@Override
public void remove(Component component) {
    if (indexOfComponent(component) < 0) {
        JFrame frame = getFrameOf(component);
        if (frame != null) {
            frame.dispose();
        }
        DisplayKind kind = ((Display) component).getKind();
        this.detachedMap.remove(kind);
    } else {
        if (getSelectedComponent() == component) {
            revertSelection();
        }
        super.remove(component);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:21,代码来源:DisplaysPanel.java

示例5: setDefaultMenuBar

import javax.swing.JFrame; //导入方法依赖的package包/类
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:_AppMenuBarHandler.java

示例6: run

import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
public void run() {
    final JFrame frame = new DeprecatedFrame();
    try {
        final JMenuBar bar = new JMenuBar();
        frame.setJMenuBar(bar);
        frame.setBounds(100, 100, 100, 100);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        if (bar != frame.getJMenuBar()) {
            throw new RuntimeException("Wrong JMenuBar");
        }
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SilenceOfDeprecatedMenuBar.java

示例7: run

import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
public void run() {
    JFrame jframe = new JFrame(windowLabel == null
            ? getResourceString("editpad.name")
            : windowLabel);
    Runnable closer = () -> {
        jframe.setVisible(false);
        jframe.dispose();
        closeMark.run();
    };
    jframe.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closer.run();
        }
    });
    jframe.setLocationRelativeTo(null);
    jframe.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea(initialText);
    textArea.setFont(new Font("monospaced", Font.PLAIN, 13));
    jframe.add(new JScrollPane(textArea), BorderLayout.CENTER);
    jframe.add(buttons(closer, textArea), BorderLayout.SOUTH);

    jframe.setSize(800, 600);
    jframe.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:EditPad.java

示例8: drawAndSave

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void drawAndSave(JPanel graphDrawing, String fileName, int canvasSize) {
	JFrame frame = new JFrame("Drawing");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.add(graphDrawing);
	frame.setSize(canvasSize, canvasSize);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	exportToImage("jpg", graphDrawing, fileName);
	frame.dispose();
}
 
开发者ID:tslaats,项目名称:SE2017-Team1,代码行数:11,代码来源:TestUtil.java

示例9: run

import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
public void run() {
    final JFrame mainFrame = new JFrame();
    try {
        testDefaultFont(mainFrame);
    } finally {
        mainFrame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:bug6421058.java

示例10: run

import javax.swing.JFrame; //导入方法依赖的package包/类
public void run() {
    String title = getClass().getName();
    JFrame frame = new JFrame(title);
    frame.setVisible(true);

    Color color = JColorChooser.showDialog(frame, title, Color.BLACK);
    if (color != null) {
        throw new Error("unexpected color: " + color);
    }
    frame.setVisible(false);
    frame.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test6541987.java

示例11: testVisibleChildParentDispose

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Test if a dialog fire the WINDOW_CLOSED event
 * on parent dispose().
 * @throws Exception
 */
public static void testVisibleChildParentDispose() throws Exception {
    JFrame f = new JFrame();
    JDialog dlg = new JDialog(f);
    Listener l = new Listener();
    dlg.addWindowListener(l);
    dlg.setVisible(true);
    f.dispose();
    waitEvents();

    assertEquals(1, l.getCount());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:WindowClosedEventOnDispose.java

示例12: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
    final JFrame frame = new DrawBitmaskToSurfaceTest();
    frame.setBounds(10, 350, 200, 200);
    frame.setVisible(true);

    Thread.sleep(2000);

    System.err.println("Change frame bounds...");
    latch = new CountDownLatch(1);
    frame.setBounds(10, 350, 90, 90);
    frame.repaint();

    try {
        if (latch.getCount() > 0) {
            latch.await();
        }
    } catch (InterruptedException e) {
    }

    frame.dispose();

    if (theError != null) {
        throw new RuntimeException("Test failed.", theError);
    }

    System.err.println("Test passed");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:DrawBitmaskToSurfaceTest.java

示例13: doStep

import javax.swing.JFrame; //导入方法依赖的package包/类
public void doStep() {
    JFrame f = getFrame();
    if (f != null) {
        f.dispose();
    }
    System.out.println("Done");

    testDone.countDown();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:CustomComboBoxFocusTest.java

示例14: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (!Platform.isWindows()) {
        System.out.println("Only Windows platform test. Test is skipped.");
        System.out.println("ok");
        return;
    }
    final String lafClassName = UIManager.getSystemLookAndFeelClassName();
    lafClass  = Class.forName(lafClassName);
    UIManager.setLookAndFeel(lafClassName);
    try {
        SwingUtilities.invokeAndWait(() -> {
            frame = new JFrame();
            frame.setUndecorated(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setup(frame);
        });

        final Robot robot = new Robot();
        robot.waitForIdle();
        robot.setAutoDelay(20);
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_F);
        robot.keyRelease(KeyEvent.VK_F);
        robot.keyRelease(KeyEvent.VK_ALT);
        robot.waitForIdle();
        checkMnemonics();

        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_ALT);
        robot.waitForIdle();
        checkMnemonics();
        System.out.println("ok");
    } finally {
        if (frame != null) { frame.dispose(); }
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:bug6921687.java

示例15: testHidenWindowDispose

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Test if a Window that has never been shown fire the
 * WINDOW_CLOSED event on dispose()
 */
public static void testHidenWindowDispose() throws Exception {
    JFrame f = new JFrame();
    Listener l = new Listener();
    f.addWindowListener(l);
    f.dispose();
    waitEvents();

    assertEquals(0, l.getCount());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:WindowClosedEventOnDispose.java


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