Example usage for java.awt Frame Frame

List of usage examples for java.awt Frame Frame

Introduction

In this page you can find the example usage for java.awt Frame Frame.

Prototype

public Frame() throws HeadlessException 

Source Link

Document

Constructs a new instance of Frame that is initially invisible.

Usage

From source file:com.projity.main.EclipseMain.java

public static void main(String args[]) {
    Frame frame = new Frame();
    createGraphicManager(frame, null);
}

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;/*  w  w  w. j  av  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, 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:Snippet156.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 2s .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;//from  w w  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:RadialLayout.java

/**
 * Run a demonstration.//from  w w w.j a v  a2  s.  c  o  m
 *
 * @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:Main.java

public static void main() {
    Frame frame = new Frame();
    frame.setResizable(false);/*www .ja  v a 2 s.  com*/

    boolean resizable = frame.isResizable();
}

From source file:Main.java

public static void main() {
    Frame frame = new Frame();
    frame.setUndecorated(true);//from  w w  w .j a  va  2 s .c  o  m

    // Get the current decorated state
    boolean undecorated = frame.isUndecorated();
}

From source file:Main.java

public static void main() {

    Frame frame = new Frame();

    frame.setSize(300, 300);
    frame.setVisible(true);

    iconify(frame);
}

From source file:Main.java

public static void main() {

    Frame frame = new Frame();

    Rectangle bounds = new Rectangle(20, 20, 200, 200);

    frame.setMaximizedBounds(bounds);//ww w. ja  va2 s  . c o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main() {
    Frame frame = new Frame();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            Frame frame = (Frame) evt.getSource();
            frame.setVisible(false);//  w  ww . j a  va  2  s . c  o m
            // frame.dispose();
        }
    });
}