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:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new JTable(new Object[][] { { 1, 2, 3 }, { 4, 5, 6 } }, new Object[] { "one", "two", "three" }) {
        {//from w  ww.ja v a 2 s .  c  o m
            addMouseMotionListener(new MouseAdapter() {
                @Override
                public void mouseDragged(MouseEvent e) {
                    System.out.println("mouseDragged");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    System.out.println("mousePressed");
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    System.out.println("mouseReleased");
                }
            });
        }
    });
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Main());
    f.pack();/*ww  w .  ja  va 2s.c o m*/
    f.setSize(new Dimension(300, 200));
    f.setVisible(true);

}

From source file:LinesDashes1.java

public static void main(String[] args) {
    LinesDashes1 lines = new LinesDashes1();
    JFrame frame = new JFrame("Lines");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(lines);
    frame.setSize(280, 270);//from  ww w  .java 2  s.  com
    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 HighlightLineTextPane());
    frame.setBounds(100, 100, 300, 400);
    frame.setVisible(true);/*from   w  ww  .ja  v  a  2  s  . co m*/
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame("ListPanel");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Main());
    f.pack();/*from  www  .j a  v  a2  s . c o m*/
    f.setVisible(true);

}

From source file:Rectangles.java

public static void main(String[] args) {
    Rectangles rects = new Rectangles();
    JFrame frame = new JFrame("Rectangles");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(rects);
    frame.setSize(360, 300);/*from   ww  w. j  ava2  s  . com*/
    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 ClockPane());
    frame.pack();//w  w w .j a  v  a2 s  .co  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;
    int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;
    boolean continuousLayout = true;
    JLabel label1 = new JLabel("a");
    JLabel label2 = new JLabel("b");
    JLabel label3 = new JLabel("c");
    JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerSize(2);/*  w ww.j  a v a  2  s .  c o m*/
    splitPane1.setDividerLocation(0.5);

    JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3);
    splitPane2.setOneTouchExpandable(true);
    splitPane2.setDividerLocation(0.4);
    splitPane2.setDividerSize(2);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(splitPane2);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel pane = newPane("Label in frame");
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(pane);
    frame.pack();//from  w  w w.j  a  v  a2  s  .co  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel();
    panel.add(new JTextField(10));
    panel.add(new JButton("button"));
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.pack();/*w w w  .  j ava 2 s  .c o  m*/
    frame.setVisible(true);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowIconified(WindowEvent wEvt) {
            ((JFrame) wEvt.getSource()).dispose();
        }

        @Override
        public void windowDeactivated(WindowEvent wEvt) {
            ((JFrame) wEvt.getSource()).dispose();
        }
    });
}