Example usage for java.awt Frame add

List of usage examples for java.awt Frame add

Introduction

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

Prototype

public Component add(String name, Component comp) 

Source Link

Document

Adds the specified component to this container.

Usage

From source file:Main.java

public static void main(String[] args) throws HeadlessException, AWTException {
    Frame frame = new Frame();
    Button button1 = new Button("Ok");
    frame.add(button1, BorderLayout.NORTH);
    frame.setSize(50, 55);//from   w  w  w.ja  va2  s .  co m
    frame.setVisible(true);

    button1.setCursor(Cursor.getSystemCustomCursor("MoveDrop.32x32"));
}

From source file:Main.java

public static void main(String args[]) {
    Frame f = new Frame();
    JPanel mgb = new Main();
    f.add("Center", mgb);
    f.pack();/*from  w w w . j a va2 s.  c  o  m*/
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:HelloWorld.java

public static void main(String[] args) {
    Frame frame = new Frame();
    frame.setSize(640, 480);//from  www  .ja  v  a 2  s  . c om
    frame.setLayout(new BorderLayout());

    Canvas3D canvas = new Canvas3D(null);
    frame.add("Center", canvas);

    SimpleUniverse univ = new SimpleUniverse(canvas);
    univ.getViewingPlatform().setNominalViewingTransform();

    BranchGroup scene = createSceneGraph();
    scene.compile();
    univ.addBranchGraph(scene);

    frame.show();
}

From source file:Drag.java

/**
 *  Used when running as an application.
 *//*  w ww  .  j  a v a  2  s.  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: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);/*ww  w .ja  va 2 s  .c om*/
        }
    });
    Applet applet = new ShapeMover();
    f.add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(550, 250));
    f.show();
}

From source file:WebCrawler.java

public static void main(String argv[]) {
    Frame f = new Frame("WebFrame");
    WebCrawler applet = new WebCrawler();
    f.add("Center", applet);

    /*    Behind a firewall set your proxy and port here!
    *//*w  w  w .ja  v  a  2  s  . c om*/
    Properties props = new Properties(System.getProperties());
    props.put("http.proxySet", "true");
    props.put("http.proxyHost", "webcache-cup");
    props.put("http.proxyPort", "8080");

    Properties newprops = new Properties(props);
    System.setProperties(newprops);
    /**/

    applet.init();
    applet.start();
    f.pack();
    f.show();
}

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);//from   w  w  w . j a  v a2  s  .co m
    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 source file:ImageBouncer.java

public static void main(String[] args) {
    String filename = "java2sLogo.png";
    if (args.length > 0)
        filename = args[0];/*from   w w w . j  a v  a 2s . co  m*/

    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  w w. ja va 2s  .com

    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:de.prozesskraft.pkraft.Createdoc.java

/**
 * Create contents of the window.//from w  ww. j  a  va 2 s.  com
 */
protected static void createContents(PmodelViewPage page) {
    shell = new Shell();
    shell.setSize(3500, 1500);
    shell.setText("SWT Application");
    shell.setLayout(new GridLayout(1, false));

    Composite composite = new Composite(shell, SWT.NONE);

    GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite.minimumWidth = 10;
    gd_composite.minimumHeight = 10;
    composite.setLayoutData(gd_composite);
    composite.setLayout(new GridLayout(1, false));

    Composite composite2 = new Composite(composite, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    GridData gd_composite2 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite2.minimumWidth = 10;
    gd_composite2.minimumHeight = 10;
    composite2.setLayoutData(gd_composite2);

    Frame frame = SWT_AWT.new_Frame(composite2);

    //      Label lblNewLabel = new Label(composite, SWT.BORDER);
    //      lblNewLabel.setBounds(100, 10, 66, 17);
    //      lblNewLabel.setText("sxsdsds");

    frame.add(page, BorderLayout.CENTER);
    page.init();
    frame.pack();
    frame.setLocation(0, 0);
    frame.setVisible(true);

    page.refresh();
}