List of usage examples for java.awt Frame setSize
public void setSize(int width, int height)
The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .
From source file:Bouncer.java
public static void main(String[] args) { final Bouncer bouncer = new Bouncer(); Frame f = new AnimationFrame(bouncer); f.setFont(new Font("Serif", Font.PLAIN, 12)); f.setSize(200, 200); Panel controls = new Panel(); controls.add(bouncer.createCheckbox("Anti.", Bouncer.ANTIALIASING)); controls.add(bouncer.createCheckbox("Trans.", Bouncer.TRANSFORM)); controls.add(bouncer.createCheckbox("Gradient", Bouncer.GRADIENT)); controls.add(bouncer.createCheckbox("Outline", Bouncer.OUTLINE)); controls.add(bouncer.createCheckbox("Dotted", Bouncer.DOTTED)); controls.add(bouncer.createCheckbox("Axes", Bouncer.AXES)); controls.add(bouncer.createCheckbox("Clip", Bouncer.CLIP)); f.add(controls, BorderLayout.NORTH); f.setVisible(true);/*from w w w . jav a 2s . co m*/ }
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();//www.ja v a 2 s . com 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:RadialLayout.java
/** * Run a demonstration.//from w ww.j ava 2 s. c om * * @param args ignored. * * @throws Exception when an error occurs. */ public static void main(final String[] args) throws Exception { final Frame frame = new Frame(); final Panel panel = new Panel(); panel.setLayout(new RadialLayout()); panel.add(new Checkbox("One")); panel.add(new Checkbox("Two")); panel.add(new Checkbox("Three")); panel.add(new Checkbox("Four")); panel.add(new Checkbox("Five")); panel.add(new Checkbox("One")); panel.add(new Checkbox("Two")); panel.add(new Checkbox("Three")); panel.add(new Checkbox("Four")); panel.add(new Checkbox("Five")); frame.add(panel); frame.setSize(300, 500); frame.setVisible(true); }
From source file:Snippet156.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SWT Image"); ImageData data;//from www. j a v a 2 s . c om if (args.length > 0) { String fileName = args[0]; data = new ImageData(fileName); } else { data = createSampleImage(display); } final Image swtImage = new Image(display, data); final BufferedImage awtImage = convertToAWT(data); final Image swtImage2 = new Image(display, convertToSWT(awtImage)); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { int y = 10; if (swtImage != null) { e.gc.drawImage(swtImage, 10, y); y += swtImage.getBounds().height + 10; } if (swtImage2 != null) { e.gc.drawImage(swtImage2, 10, y); } } }); Frame frame = new Frame() { public void paint(Graphics g) { Insets insets = getInsets(); if (awtImage != null) { g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null); } } }; frame.setTitle("AWT Image"); shell.setLocation(50, 50); Rectangle bounds = swtImage.getBounds(); shell.setSize(bounds.width + 50, bounds.height * 2 + 100); Point size = shell.getSize(); Point location = shell.getLocation(); Insets insets = frame.getInsets(); frame.setLocation(location.x + size.x + 10, location.y); frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom)); frame.setVisible(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (swtImage != null) swtImage.dispose(); if (swtImage2 != null) swtImage.dispose(); frame.dispose(); System.exit(0); }
From source file:AWTBufferedImageSWTImage.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SWT Image"); ImageData data;// ww w . j a v a 2 s . c o m if (args.length > 0) { String fileName = args[0]; data = new ImageData(fileName); } else { data = createSampleImage(display); } final Image swtImage = new Image(display, data); final BufferedImage awtImage = convertToAWT(data); final Image swtImage2 = new Image(display, convertToSWT(awtImage)); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { int y = 10; if (swtImage != null) { e.gc.drawImage(swtImage, 10, y); y += swtImage.getBounds().height + 10; } if (swtImage2 != null) { e.gc.drawImage(swtImage2, 10, y); } } }); Frame frame = new Frame() { public void paint(Graphics g) { Insets insets = getInsets(); if (awtImage != null) { g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null); } } }; frame.setTitle("AWT Image"); shell.setLocation(50, 50); Rectangle bounds = swtImage.getBounds(); shell.setSize(bounds.width + 50, bounds.height * 2 + 100); Point size = shell.getSize(); Point location = shell.getLocation(); Insets insets = frame.getInsets(); frame.setLocation(location.x + size.x + 10, location.y); frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom)); frame.setVisible(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (swtImage != null) swtImage.dispose(); if (swtImage2 != null) swtImage.dispose(); frame.dispose(); display.dispose(); /* * Note: If you are using JDK 1.3.x, you need to use System.exit(0) at the * end of your program to exit AWT. This is because in 1.3.x, AWT does not * exit when the frame is disposed, because the AWT thread is not a daemon. * This was fixed in JDK 1.4.x with the addition of the AWT Shutdown thread. */ }
From source file:org.eclipse.swt.snippets.Snippet156.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SWT Image"); ImageData data;/*from w w w . ja va 2s. c o m*/ if (args.length > 0) { String fileName = args[0]; data = new ImageData(fileName); } else { data = createSampleImage(display); } final Image swtImage = new Image(display, data); final BufferedImage awtImage = convertToAWT(data); final Image swtImage2 = new Image(display, convertToSWT(awtImage)); shell.addListener(SWT.Paint, e -> { int y = 10; if (swtImage != null) { e.gc.drawImage(swtImage, 10, y); y += swtImage.getBounds().height + 10; } if (swtImage2 != null) { e.gc.drawImage(swtImage2, 10, y); } }); Frame frame = new Frame() { @Override public void paint(Graphics g) { Insets insets = getInsets(); if (awtImage != null) { g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null); } } }; frame.setTitle("AWT Image"); shell.setLocation(50, 50); Rectangle bounds = swtImage.getBounds(); shell.setSize(bounds.width + 50, bounds.height * 2 + 100); Point size = shell.getSize(); Point location = shell.getLocation(); Insets insets = frame.getInsets(); frame.setLocation(location.x + size.x + 10, location.y); frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom)); frame.setVisible(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (swtImage != null) swtImage.dispose(); if (swtImage2 != null) swtImage.dispose(); frame.dispose(); display.dispose(); /* Note: If you are using JDK 1.3.x, you need to use System.exit(0) at the end of your program to exit AWT. * This is because in 1.3.x, AWT does not exit when the frame is disposed, because the AWT thread is not a daemon. * This was fixed in JDK 1.4.x with the addition of the AWT Shutdown thread. */ }
From source file:ImageBouncer.java
public static void main(String[] args) { String filename = "java2sLogo.png"; if (args.length > 0) filename = args[0];// ww w . java2s . c om Image image = null; try { image = blockingLoad(new URL(filename)); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } final ImageBouncer bouncer = new ImageBouncer(image); Frame f = new AnimationFrame(bouncer); f.setFont(new Font("Serif", Font.PLAIN, 12)); Panel controls = new Panel(); controls.add(bouncer.createCheckbox("Bilinear", ImageBouncer.BILINEAR)); controls.add(bouncer.createCheckbox("Transform", ImageBouncer.TRANSFORM)); final Choice typeChoice = new Choice(); typeChoice.add("TYPE_INT_RGB"); typeChoice.add("TYPE_INT_ARGB"); typeChoice.add("TYPE_INT_ARGB_PRE"); typeChoice.add("TYPE_3BYTE_BGR"); typeChoice.add("TYPE_BYTE_GRAY"); typeChoice.add("TYPE_USHORT_GRAY"); typeChoice.add("TYPE_USHORT_555_RGB"); typeChoice.add("TYPE_USHORT_565_RGB"); controls.add(typeChoice); f.add(controls, BorderLayout.NORTH); typeChoice.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { String type = typeChoice.getSelectedItem(); bouncer.setImageType(type); } }); f.setSize(200, 200); f.setVisible(true); }
From source file:TextBouncer.java
public static void main(String[] args) { String s = "Java Source and Support"; final int size = 64; if (args.length > 0) s = args[0];/*from w ww .j a va 2s . c o m*/ Panel controls = new Panel(); final Choice choice = new Choice(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] allFonts = ge.getAllFonts(); for (int i = 0; i < allFonts.length; i++) choice.addItem(allFonts[i].getName()); Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size); final TextBouncer bouncer = new TextBouncer(s, defaultFont); Frame f = new AnimationFrame(bouncer); f.setFont(new Font("Serif", Font.PLAIN, 12)); controls.add(bouncer.createCheckbox("Antialiasing", TextBouncer.ANTIALIASING)); controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT)); controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR)); controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE)); controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES)); Panel fontControls = new Panel(); choice.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size); bouncer.setFont(font); } }); fontControls.add(choice); Panel allControls = new Panel(new GridLayout(2, 1)); allControls.add(controls); allControls.add(fontControls); f.add(allControls, BorderLayout.NORTH); f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main() { Frame frame = new Frame(); frame.setSize(300, 300); frame.setVisible(true);/*from w w w . jav a2 s . co m*/ iconify(frame); }
From source file:Main.java
public static void fullWindow(Frame frame) { // Get the size of the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize(dim.width, dim.height); // Move the window frame.setLocation(0, 0);//from w w w . ja v a 2 s . c o m }