Java Code Examples for
javax.swing.JFrame
#
dispose()
javax.swing.JFrame #dispose()
The following examples show how to use. You can vote up the ones you like or vote down the ones you don’t like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project:
netbeans
File: DrawEngineTest.java
License: Apache License 2.0
7
votes
@RandomlyFails public void testModelToViewCorrectness() throws Throwable { for(String text : TEXTS) { JEditorPane jep = createJep(text); try { checkModelToViewCorrectness(jep); } catch (Throwable e) { System.err.println("testModelToViewCorrectness processing {"); System.err.println(text); System.err.println("} failed with:"); e.printStackTrace(); throw e; } finally { JFrame frame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jep); if (frame != null) { frame.dispose(); } } } }
Example 2
Source Project:
netbeans
File: DrawEngineTest.java
License: Apache License 2.0
6
votes
@RandomlyFails public void testModelToViewConsistency() throws Throwable { for(String text : TEXTS) { JEditorPane jep = createJep(text); try { checkModelToViewConsistency(jep); } catch (Throwable e) { System.err.println("testModelToViewConsistency processing {"); System.err.println(text); System.err.println("} failed with:"); e.printStackTrace(); throw e; } finally { JFrame frame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jep); if (frame != null) { frame.dispose(); } } } }
Example 3
Source Project:
SciGraph
File: ImageWriter.java
License: Apache License 2.0
5
votes
private static BufferedImage renderImage(JPanel panel) { JFrame frame = new JFrame(); frame.setUndecorated(true); frame.getContentPane().add(panel); frame.pack(); BufferedImage bi = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bi.createGraphics(); panel.print(graphics); graphics.dispose(); frame.dispose(); return bi; }
Example 4
Example 5
Source Project:
jdk8u-jdk
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * Test if a dialog that has never been shown fire * the WINDOW_CLOSED event on parent dispose(). * @throws Exception */ public static void testHidenChildDispose() throws Exception { JFrame f = new JFrame(); JDialog dlg = new JDialog(f); Listener l = new Listener(); dlg.addWindowListener(l); f.dispose(); waitEvents(); assertEquals(0, l.getCount()); }
Example 6
Source Project:
marathonv5
File: AnnotateScreenCapture.java
License: Apache License 2.0
5
votes
public File saveToFile(File captureFile) throws FileNotFoundException, IOException { writePNG(captureFile); ImageReader reader = getPNGImageReader(); ImageInputStream iis = ImageIO.createImageInputStream(new FileInputStream(captureFile)); reader.setInput(iis); BufferedImage pngImage = reader.read(0); IIOMetadata imageMetadata = reader.getImageMetadata(0); Node root = imageMetadata.getAsTree(imageMetadata.getNativeMetadataFormatName()); IIOMetadataNode textNode = new IIOMetadataNode("tEXt"); ArrayList<Annotation> annotations = imagePanel.getAnnotations(); for (int i = 0; i < annotations.size(); i++) { textNode.appendChild(getAnnotationNode((Annotation) annotations.get(i), i)); } root.appendChild(textNode); imageMetadata.mergeTree(imageMetadata.getNativeMetadataFormatName(), root); IIOImage imageWrite = new IIOImage(pngImage, new ArrayList<BufferedImage>(), imageMetadata); ImageWriter writer = getPNGImageWriter(); ImageOutputStream ios = ImageIO.createImageOutputStream(new FileOutputStream(captureFile)); writer.setOutput(ios); writer.write(imageWrite); writer.dispose(); JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); ImagePanel finalImage = new ImagePanel(new FileInputStream(captureFile), false); frame.add(finalImage, BorderLayout.CENTER); frame.pack(); File savedFile = new File(captureFile.getParentFile(), "ext-" + captureFile.getName()); getScreenShot(frame.getContentPane(), savedFile); frame.dispose(); return savedFile; }
Example 7
Source Project:
dragonwell8_jdk
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * 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()); }
Example 8
Example 9
Source Project:
jdk8u60
File: Test6541987.java
License: GNU General Public License v2.0
5
votes
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(); }
Example 10
Source Project:
jdk8u_jdk
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * 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()); }
Example 11
Source Project:
jdk8u-dev-jdk
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * 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()); }
Example 12
Example 13
Example 14
Example 15
Source Project:
jdk8u_jdk
File: DrawBitmaskToSurfaceTest.java
License: GNU General Public License v2.0
5
votes
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"); }
Example 16
Source Project:
jdk8u-jdk
File: Test6541987.java
License: GNU General Public License v2.0
5
votes
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(); }
Example 17
Example 18
Source Project:
jdk8u_jdk
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * 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()); }
Example 19
Source Project:
openjdk-jdk8u
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * 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()); }
Example 20
Source Project:
jdk8u60
File: WindowClosedEventOnDispose.java
License: GNU General Public License v2.0
5
votes
/** * Test if a dialog that has never been shown fire * the WINDOW_CLOSED event on parent dispose(). * @throws Exception */ public static void testHidenChildDispose() throws Exception { JFrame f = new JFrame(); JDialog dlg = new JDialog(f); Listener l = new Listener(); dlg.addWindowListener(l); f.dispose(); waitEvents(); assertEquals(0, l.getCount()); }