Java 8 JFrame - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JFrame class.

This code example shows how to use the following methods:setSize, setVisible, setDefaultCloseOperation, setLayout, add
    boolean cpu = true;
    if(args.length == 1 && args[0].equals("-gpu")){
      cpu = false;
    }     
 
    JFrame f = new JFrame();
    f.setSize(256, 256);
    f.setLayout(new GridLayout());
    f.add(new NewJPanel(cpu));
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  } 
} 
8
CodeRank
This code example shows how to use the following methods:pack, setVisible, setDefaultCloseOperation, add
	static { 
		Webcam.setDriver(new JavaCvDriver()); 
	} 
 
	public static void main(String[] args) {
		JFrame frame = new JFrame("LTI-CIVIL Webcam Capture Driver Example");
		frame.add(new WebcamPanel(Webcam.getDefault()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:pack, setVisible, setContentPane, setDefaultCloseOperation
  public static JFrame createAndShowGUI() {
    //Make sure we have nice window decorations. 
    JFrame.setDefaultLookAndFeelDecorated(true);
 
    //Create and set up the window. 
    JFrame frame = new JFrame("DragListDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
    //Create and set up the content pane. 
    DragListDemo demo = new DragListDemo();
    frame.setContentPane(demo);
 
    //Display the window. 
    frame.pack();
    frame.setVisible(true);
    return frame;
  } 
 
  public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread: 
7
CodeRank
This code example shows how to use the following methods:pack, show, getContentPane
import com.ochafik.io.ReadText; 
 
public class Test { 
	@SuppressWarnings("deprecation") 
	public static void main(String args[]) {
		JFrame f=new JFrame("Test");
		String text=args.length==0 ? "" : ReadText.readText(new File(args[0]));
		JEditTextArea ta=new JEditTextArea();
		ta.setText(text);
		f.getContentPane().add("Center",new JScrollPane(ta));
		f.pack();
		f.show();
	} 
} 
7
CodeRank
This code example shows how to use the following methods:pack, setVisible, setDefaultCloseOperation, add
	static { 
		Webcam.setDriver(new LtiCivilDriver()); 
	} 
 
	public static void main(String[] args) {
		JFrame frame = new JFrame("LTI-CIVIL Webcam Capture Driver Example");
		frame.add(new WebcamPanel(Webcam.getDefault()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:pack, setDefaultCloseOperation, add
	protected final VideoPanel videoPannel;
	protected final JFrame window;
 
	public SingleVideoDisplayWindow(String name,Dimension dimension) {
		super(); 
		this.window = new JFrame(name);
		this.videoPannel = new VideoPanel();
 
		this.videoPannel.setPreferredSize(dimension);
		this.window.add(videoPannel);
		this.window.pack();
		this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
 
	public void setVisible(boolean visible) {
		this.window.setVisible(visible);
	} 
 
	public void updateImage(BufferedImage image) {
		videoPannel.updateImage(image);
7
CodeRank
This code example shows how to use the following methods:add, validate, setSize, setVisible, sleep
    @Test(groups = "display-required") // Will fail if run in a headless environment.
    public void testUserSelection() throws InterruptedException
    { 
        Robot robot = BasicRobot.robotWithNewAwtHierarchy();
        final SwingConsole swingConsole = new SwingConsole();
        JFrame frame = new JFrame();
        frame.add(swingConsole, BorderLayout.CENTER);
        FrameFixture frameFixture = new FrameFixture(robot, frame);
        frame.setSize(300, 100);
        frame.validate();
        frame.setVisible(true);
 
        final List<JLabel> labels = Arrays.asList(new JLabel("Zero"),
                                                  new JLabel("One"),
                                                  new JLabel("Two"));
 
        final int[] selection = new int[1];
        new Thread(new Runnable()
        { 
            public void run() 

7
CodeRank
This code example shows how to use the following methods:pack, setSize, setVisible, getContentPane
System.exit(0);
    } 
     
    public static void main(String[] args) {
        JFrame f = new JFrame("Rendering Test");
        f.setSize(500, 500);
        f.getContentPane().add(new RenderingBenchmarks());
        f.pack();
        f.setVisible(true);
    } 
     
} 
7
CodeRank
This code example shows how to use the following methods:pack, setLocation, setVisible, setContentPane, setDefaultCloseOperation
This code example shows how to use the following methods:validate, pack, setSize, setVisible, getContentPane
        final GLCapabilities caps = new GLCapabilities(glp);
        final GLCanvas glCanvas = new GLCanvas(caps);
        glCanvas.addGLEventListener(new GearsES2());
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() { 
                frame.getContentPane().add(glCanvas);
                frame.pack();
                frame.setSize(512, 512);
                frame.validate();
                frame.setVisible(true);
            } }); 
        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
        Assert.assertEquals(true,  AWTRobotUtil.waitForRealized(glCanvas, true));
 
        // 
        // close with op: DO_NOTHING_ON_CLOSE -> NOP / HIDE (default) 
        // 
        Assert.assertEquals(WindowConstants.HIDE_ON_CLOSE, frame.getDefaultCloseOperation());
        WindowClosingMode op = glCanvas.getDefaultCloseOperation();
        Assert.assertEquals(WindowClosingMode.DO_NOTHING_ON_CLOSE, op);
7
CodeRank
See Code Examples for Java 8 JFrame Methods: