List of usage examples for java.awt Frame Frame
public Frame(String title) throws HeadlessException
From source file:Main.java
public static void main(String args[]) throws Exception { // Create a test frame Frame frame = new Frame("Hello"); frame.add(new Label("Minimize demo")); frame.pack();/*from w ww.ja va 2 s . c o m*/ // Show the frame frame.setVisible(true); // Sleep for 5 seconds, then minimize Thread.sleep(5000); frame.setState(Frame.ICONIFIED); frame.setVisible(false); // Sleep for 5 seconds, then restore Thread.sleep(5000); frame.setState(Frame.NORMAL); frame.setVisible(true); // Sleep for 5 seconds, then kill window Thread.sleep(5000); frame.setVisible(false); frame.dispose(); // Terminate test System.exit(0); }
From source file:Main.java
public static void main(String[] args) { Frame f = new Frame("FlowLayout demo"); f.setLayout(new FlowLayout()); f.add(new Button("Red")); f.add(new Button("Blue")); f.add(new Button("White")); List list = new List(); for (int i = 0; i < args.length; i++) { list.add(args[i]);/* w ww . ja v a 2 s. co m*/ } f.add(list); f.add(new Checkbox("Pick me", true)); f.add(new Label("Enter name here:")); f.add(new TextField(20)); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); Button btn = new Button("OK"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); gs.setFullScreenWindow(null); }/*from w ww. j ava 2 s . c o m*/ }); Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); win.add(btn, BorderLayout.CENTER); try { gs.setFullScreenWindow(win); win.validate(); } finally { gs.setFullScreenWindow(null); } }
From source file:ShapeMover.java
public static void main(String s[]) { Frame f = new Frame("ShapeMover"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w .ja va2 s. com*/ } }); Applet applet = new ShapeMover(); f.add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(550, 250)); f.show(); }
From source file:FrameIcon.java
/** Demo main program, showing two ways to use it. * Create a small MemImage and set it as this Frame's iconImage. * Also display a larger version of the same image in the Frame. *///from w w w . j av a 2 s . co m public static void main(String[] av) { Frame f = new Frame("FrameIcon"); Image im = Toolkit.getDefaultToolkit().getImage("java2s.gif"); f.setIconImage(im); f.setSize(100, 100); f.setLocation(200, 200); f.setVisible(true); }
From source file:MemImage.java
/** * Demo main program, showing two ways to use it. Create a small MemImage * and set it as this Frame's iconImage. Also display a larger version of * the same image in the Frame.//w w w . j a v a2 s .c om */ public static void main(String[] av) { Frame f = new Frame("MemImage.java"); f.add(new MemImage()); f.setIconImage(new MemImage(16, 16).getImage()); f.pack(); f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { Frame frame = new Frame("AppletAndApp as an Application"); myApplet = new MainClass(); frame.add(new Panel().add(myApplet)); frame.addNotify();// w w w . j a v a 2 s . c o m myApplet.setStub(myStub = new MyStub(args)); myApplet.init(); frame.setSize(300, 200); frame.setVisible(true); myStub.setActive(true); myApplet.start(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent w) { myStub.setActive(false); myApplet.stop(); myApplet.destroy(); System.exit(0); } }); }
From source file:TexturedText.java
/** "main program" method - construct and show */ public static void main(String[] av) { // create a TexturedText object, tell it to show up final Frame f = new Frame("TexturedText"); TexturedText comp = new TexturedText(); f.add(comp);/* w ww. ja v a 2 s. c o m*/ f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { f.setVisible(false); f.dispose(); System.exit(0); } }); f.pack(); f.setLocation(200, 200); f.setVisible(true); }
From source file:Drag.java
/** * Used when running as an application. *///from ww w .j av a 2s .c o m public static void main(String[] args) { Drag drag = new Drag(); drag.setAppletFlag(false); drag.init(); Frame frame = new Frame("Drag the mouse in the window"); frame.setSize(640, 480); frame.add("Center", drag); frame.addWindowListener(new killAdapter()); frame.setVisible(true); }
From source file:Main.java
static Window getDialog(Component parentComponent, String title, boolean modal) { if (ALWAYS_USE_FRAME) return new Frame(title); Window dialog;/*from ww w .j a v a 2s.c o m*/ Window window = getComponentWindow(parentComponent); if (window instanceof Frame) { dialog = new Dialog((Frame) window, title, modal); } else { dialog = new Dialog((Dialog) window, title, modal); } return dialog; }