Java Code Examples for javax.swing.JFrame#show()

The following examples show how to use javax.swing.JFrame#show() . These examples are extracted from open source projects. 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
public static void main(String[] args) {
	    JFrame f = new JFrame();
	    WebLookAndFeel.install();
	    JPanel panel = new JPanel(new GridLayout(1, 17));
	    f.getContentPane().add(panel);
//	for (int i=0; i<17; i++) {
//		WebStyledLabel icon = new WebStyledLabel (WebLookAndFeel.getIcon(i));
//		panel.add(icon);
//	}
   

//    f.getContentPane().add(new TexturedText());
	
    f.setSize(800, 200);
    f.show();

  }
 
Example 2
Source Project: pdfxtk   File: HilightImagePanel.java    License: Apache License 2.0 6 votes vote down vote up
/** Test program */

  public static void main(String[] arg) {
    PlanarImage image = JAI.create("fileload", arg[0]);
    PlanarImage mask  = JAI.create("fileload", arg[1]);

    JFrame window = new JFrame();

    window.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
	  System.exit(0);
	}
      });
    window.getContentPane().add(new HilightImagePanel(image, mask, Color.blue),
				BorderLayout.CENTER);
    window.pack();
    window.setSize(300, 300);
    window.setLocation(40, 40); 
    window.show();
  }
 
Example 3
Source Project: pdfxtk   File: XMIllumDesktop.java    License: Apache License 2.0 6 votes vote down vote up
/** Sets up the desktop */

  public JDesktopPane setupDesktop() {
    JDesktopPane desktop = new JDesktopPane();
    
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    size.width = size.width - 80;
    size.height = size.height - 40;
    
    JFrame window = new JFrame("XMIllum");
    window.addWindowListener(new WindowAdapter() {
	public void windowClosing(WindowEvent e) {
	  Preferences.store();
	  System.exit(0);
	}
      });
    window.setContentPane(desktop);
    window.pack();
    window.setSize(size);
    window.setLocation(0, 0);
    window.show();

    Preferences.watch(window);

    return desktop;
  }
 
Example 4
public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setTitle("Title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton();
    button.setText("Hello, World!");
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.pack();
    frame.setVisible(true);
    frame.show();
}
 
Example 5
Source Project: netbeans   File: FocusAfterBadEditTest.java    License: Apache License 2.0 5 votes vote down vote up
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
Example 6
Source Project: netbeans   File: RendererDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
Example 7
Source Project: netbeans   File: SheetTableTest.java    License: Apache License 2.0 5 votes vote down vote up
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
Example 8
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
Example 9
Source Project: beautyeye   File: DemoModule.java    License: Apache License 2.0 5 votes vote down vote up
/**
    * Main impl.
    */
   public void mainImpl() {
JFrame frame = new JFrame(getName());
       frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER);
getDemoPanel().setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
frame.pack();
frame.show();
   }
 
Example 10
Source Project: netbeans   File: TreeModelExample2.java    License: Apache License 2.0 5 votes vote down vote up
public static void main (String[] args) {
    TreeModelExample2 tme = new TreeModelExample2 ();
    JComponent ttv = Models.createView (
        tme,              // TreeModel
        tme,              // NodeModel
        null,             // TableModel
        null,             // NodeActionsProvider
        new ArrayList ()  // list of ColumnModels
    );
    JFrame f = new JFrame ("Tree Model Example 2");
    f.getContentPane ().add (ttv);
    f.pack ();
    f.show ();
}
 
Example 11
Source Project: netbeans   File: EditableDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
Example 12
Source Project: netbeans   File: EditableDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
/** Asserts that a pixel at a given position in an image matches a
 * pixel in a given position in a component */
private synchronized void assertPixelFromImage(String msg, final Image i, final Component c, final int imageX, final int imageY, final int compX, final int compY) throws Exception {
    final BufferedImage bi = i instanceof BufferedImage ? (BufferedImage) i : toBufferedImage(i);
    throwMe = null;
    sleep();
    
    int rgb = bi.getRGB(imageX, imageY);
    Color color = new Color(rgb);
    
    
    //uncomment the code below for diagnosing painting problems
    //and seeing which pixel you'return really checking
    JFrame jf = new JFrame("assertPixelFromImage " + count + " (look for the yellow line)") {
        public void paint(Graphics g) {
            new ImageIcon(bi).paintIcon(this, g, 25, 25);
            g.setColor(Color.YELLOW);
            g.drawLine(imageX+20, imageY+25, imageX+25, imageY+25);
        }
    };
    jf.setLocation(500,500);
    jf.setSize(100,100);
    jf.show();
    
    try {
        assertPixel(msg, c, color, compX, compY);
    } catch (Exception e) {
        throwMe = e;
    }
    if (throwMe != null) {
        throw throwMe;
    }
}
 
Example 13
Source Project: netbeans   File: EditableDisplayerTest.java    License: Apache License 2.0 5 votes vote down vote up
/** Implementation of assertPixel sans invokeAndWait  */
private synchronized void doAssertPixel(final String msg, final Component c, final Color toMatch, final int x, final int y) throws Exception {
    final BufferedImage bi = new BufferedImage(700, 700, BufferedImage.TYPE_INT_RGB);
    
    sleep();
    ((JComponent) c).paintAll(bi.getGraphics());
    sleep();
    int[] cArr = new int[3];
    bi.getData().getPixel(x, y, cArr);
    checkColor = new Color(cArr[0], cArr[1], cArr[2]);
    
    
    //uncomment the code below for diagnosing painting problems
    //and seeing which pixel you'return really checking
    JFrame jf = new JFrame("Assert pixel test " + count + " (look for the yellow line)") {
        public void paint(Graphics g) {
            new ImageIcon(bi).paintIcon(this, g, 25, 25);
            g.setColor(Color.YELLOW);
            g.drawLine(x+20, y+25, x+25, y+25);
        }
    };
    jf.setLocation(400,400);
    jf.setSize(500,500);
    jf.show();
    count++;
    
    assertEquals("Pixel test " + (count-1) + " " + msg + " - Color at " + x + "," + y + " does not match", toMatch, checkColor);
}
 
Example 14
Source Project: netbeans   File: TreeModelExample1.java    License: Apache License 2.0 5 votes vote down vote up
public static void main (String[] args) {
    TreeModelExample1 tme = new TreeModelExample1 ();
    JComponent ttv = Models.createView (
        tme,              // TreeModel
        null,             // NodeModel
        null,             // TableModel
        null,             // NodeActionsProvider
        new ArrayList ()  // list of ColumnModels
    );
    JFrame f = new JFrame ("Tree Model Example 1");
    f.getContentPane ().add (ttv);
    f.pack ();
    f.show ();
}
 
Example 15
Source Project: netbeans   File: TreeModelExample3.java    License: Apache License 2.0 5 votes vote down vote up
public void performDefaultAction (Object node) {
    try {
        JFrame f = new JFrame ("View");
        f.getContentPane ().add (new JEditorPane (((File) node).toURL ()));
        f.pack ();
        f.show ();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 16
Source Project: netbeans   File: TreeModelExample3.java    License: Apache License 2.0 5 votes vote down vote up
public static void main (String[] args) {
    TreeModelExample3 tme = new TreeModelExample3 ();
    JComponent ttv = Models.createView (
        tme,              // TreeModel
        tme,              // NodeModel
        null,             // TableModel
        tme,              // NodeActionsProvider
        new ArrayList ()  // list of ColumnModels
    );
    JFrame f = new JFrame ("Tree Model Example 3");
    f.getContentPane ().add (ttv);
    f.pack ();
    f.show ();
}
 
Example 17
Source Project: ETL_Unicorn   File: Flash.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings(StableData.TAG_DEPRECATION)
public static void main(String args[]){
	GUISample NE= new GUISample();
	JFrame frame= new JFrame("Deta ETL 1.0.2");   
       frame.setLayout(null);   
       frame.resize(800, 440);   
       frame.show();         
       frame.add(NE);   
       NE.init();
	NE.start();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 18
Source Project: netbeans   File: IndexedPropertyTest.java    License: Apache License 2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    // Create new TEditor
    te = new TEditor();
    // Create new TNode
    tn = new TNode();
    
    //Replacing NodeOp w/ JFrame to eliminate depending on full IDE init
    //and long delay while waiting for property sheet thus requested to
    //initialize
    final JFrame jf = new JFrame();
    ps = new PropertySheet();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(ps, BorderLayout.CENTER);
    jf.setLocation(30,30);
    jf.setSize(500,500);
    
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ps.setNodes(new Node[] {tn});
            //ps.setCurrentNode(tn);
            jf.show();
        }
    });
    
    jf.show();
    new ExtTestCase.WaitWindow(jf);
    
    try {
        // Wait for the initialization
        for (int i = 0; i < 10; i++) {
            final String asText = te.getAsText();
            if (asText == null || asText.equals("null")) {
                //System.out.println("null");
                Thread.sleep(1000);
            } else break;
        }
        ensurePainted(ps);
        
    } catch (Exception e) {
        fail("FAILED - Exception thrown "+e.getClass().toString());
    }
}
 
Example 19
Source Project: netbeans   File: NodeDeletionTest.java    License: Apache License 2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    // Create new TEditor
    te = new TEditor();
    // Create new TNode
    tn = new TNode();
    
    //Replacing NodeOp w/ JFrame to eliminate depending on full IDE init
    //and long delay while waiting for property sheet thus requested to
    //initialize
    final JFrame jf = new JFrame();
    ps = new PropertySheet();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(ps, BorderLayout.CENTER);
    jf.setLocation(30,30);
    jf.setSize(500,500);
    final Node[] nodes = new Node[]{tn};
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ps.setNodes(nodes);
            //ps.setCurrentNode(tn);
            jf.show();
        }
    });
    
    jf.show();
    new ExtTestCase.WaitWindow(jf);
    
    try {
        // Wait for the initialization
        for (int i = 0; i < 10; i++) {
            final String asText = te.getAsText();
            if (asText == null || asText.equals("null")) {
                //System.out.println("null");
                Thread.sleep(1000);
            } else break;
        }
        ensurePainted(ps);
        
    } catch (Exception e) {
        fail("FAILED - Exception thrown "+e.getClass().toString());
    }
}
 
Example 20
Source Project: netbeans   File: PropertySheetTest.java    License: Apache License 2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    if (setup) return;
    setup = true;
    // Create new TestProperty
    tp = new TProperty("TProperty", true);
    // Create new TEditor
    te = new TEditor();
    // Create new TNode
    tn = new TNode();
    
    LOG.info("RUNNING ON THREAD " + Thread.currentThread());
    
    //Replacing NodeOp w/ JFrame to eliminate depending on full IDE init
    //and long delay while waiting for property sheet thus requested to
    //initialize
    final JFrame jf = new JFrame();
    final PropertySheet ps = new PropertySheet();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(ps, BorderLayout.CENTER);
    jf.setLocation(30,30);
    jf.setSize(500,500);
    final Node[] nodes = new Node[]{tn};
    
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ps.setNodes(nodes);
            jf.show();
        }
    });
    
    
    jf.show();
    new ExtTestCase.WaitWindow(jf);
    
    LOG.info("Current node set ");
    try {
        
        // Wait for the initialization
        for (int i = 0; i < 10; i++) {
            final String asText = te.getAsText();
            if (asText == null || asText.equals("null")) {
                LOG.info("Checking editor getAsText - " + te.getAsText());
                //System.out.println("null");
                Thread.sleep(1000);
            } else break;
        }
        // Test if the initialization was successfull
        
        initEditorValue = te.getAsText();
        LOG.info("Got initial editor value " + initEditorValue);
        
        initPropertyValue = tp.getValue().toString();
        LOG.info("Got initial property value " + initPropertyValue);
        
        
        //Set new value to the Property
        tp.setValue("Test2");
        postChangePropertyValue = tp.getValue().toString();
        
        LOG.info("Post change property value is " + postChangePropertyValue);
        
        
        // Wait for the reinitialization
        for (int i = 0; i < 100; i++) {
            if (te.getAsText().equals(initEditorValue)) {
                //LOG.info(i + " value not updated ");;
                Thread.sleep(50);
            } else {
                LOG.info("value was updated");
                break;
            }
        }
        
        //issues 39205 & 39206 - ensure the property sheet really repaints
        //before we get the value, or the value in the editor will not
        //have changed
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                Graphics g = ps.getGraphics();
                ps.paintImmediately(0,0,ps.getWidth(), ps.getHeight());
            }
        });
        
        // Test if the reinitialization was successfull
        postChangeEditorValue = te.getAsText();
        LOG.info("postEditorChangeValue = " + postChangeEditorValue);
    } finally {
        jf.hide();
        jf.dispose();
    }
}