Example usage for javax.swing JFrame add

List of usage examples for javax.swing JFrame add

Introduction

In this page you can find the example usage for javax.swing JFrame add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:Points.java

public static void main(String[] args) {
    Points points = new Points();
    JFrame frame = new JFrame("Points");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(points);
    frame.setSize(250, 200);/* w  ww .j  a va2 s.  co m*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:GradientsMiddle.java

public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsMiddle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsMiddle());
    frame.setSize(350, 350);/* w  w  w  .j a  v a  2s  . co  m*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Textures.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Textures");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new Textures());
    frame.setSize(360, 120);// w w  w . j  a v  a  2  s . c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFrame frame = new JFrame();
    GridBagLayout gbl = new GridBagLayout();

    frame.setLayout(gbl);//  www .j  ava  2  s .c  o  m
    frame.add(new JButton("1"));
    frame.add(new JButton("2"));

    gbl.layoutContainer(frame);

    gbl.columnWeights = new double[] { 0.0f, 1.0f, 2.0f };
    gbl.rowWeights = new double[] { 0.0f, 1.0f };

    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel();
    panel.setLayout(new OverlayLayout(panel));

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.add("1", new JTextField("one"));
    tabbedPane.add("2", new JTextField("two"));
    tabbedPane.setAlignmentX(1.0f);/*from  w ww  . j  av  a2s  .c om*/
    tabbedPane.setAlignmentY(0.0f);

    JCheckBox checkBox = new JCheckBox("Add tab");
    checkBox.setOpaque(false);
    checkBox.setAlignmentX(1.0f);
    checkBox.setAlignmentY(0.0f);

    panel.add(checkBox);
    panel.add(tabbedPane);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.setSize(400, 100);
    frame.setVisible(true);
}

From source file:InvokeAndWaitExample.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(1);//from   w  ww.  j a  v a  2 s  .co m
    f.add(new InvokeAndWaitExample());
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    pane.setUI(new SpacedTabbedPaneUI());
    pane.addTab("One", new JPanel());
    pane.addTab("Two", new JPanel());
    pane.addTab("Threeeeeee", new JPanel());
    pane.addTab("Four", new JPanel());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(pane);
    frame.setSize(500, 200);//from www  .ja v a  2 s. c  o m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:GradientsVertical.java

public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsVertical");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsVertical());
    frame.setSize(350, 350);//from w w  w.  j  a v a 2  s  .  c o m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new TestPane());
    frame.pack();/*from  w ww .  j  av  a 2 s  . com*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final Timer timer;
    final JProgressBar progressBar = new JProgressBar();
    final JButton button = new JButton("Start");
    JFrame f = new JFrame();
    f.setLayout(new FlowLayout());
    f.add(progressBar);
    f.add(button);/*from   w w w .  j av a 2 s .c o m*/

    ActionListener updateProBar = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            int val = progressBar.getValue();
            if (val >= 100) {
                //  timer.stop();
                button.setText("End");
                return;
            }
            progressBar.setValue(++val);
        }
    };
    timer = new Timer(50, updateProBar);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (timer.isRunning()) {
                timer.stop();
                button.setText("Start");
            } else if (button.getText() != "End") {
                timer.start();
                button.setText("Stop");
            }
        }
    });
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setResizable(false);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}