當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。