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

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new StaticGenerator());
    f.setSize(300, 300);//w w  w  . jav  a  2 s  .  co m
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:ImageComposite.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new ImageComposite());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 210);/*from   ww w.  java2 s .c o m*/
    frame.setVisible(true);
}

From source file:PaintAllFontsFromGraphicEvironment.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setSize(400, 400);/*from  ww  w.j  a v  a  2  s.c  o m*/
    f.add(new PaintAllFontsFromGraphicEvironment());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:FadeOutImage.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Fade out");
    frame.add(new FadeOutImage());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 250);// w  w  w.  ja va 2  s . com
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Remove the first row
    model.removeRow(0);//from  w w w .  j a va2s. com

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Move the last row to the beginning of the table
    model.moveRow(model.getRowCount() - 1, model.getRowCount() - 1, 0);

    JFrame f = new JFrame();
    f.setSize(300, 300);/*  w  w w.  ja v  a 2s. c  o  m*/
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Move the last two rows to the start of the table
    model.moveRow(model.getRowCount() - 2, model.getRowCount() - 1, 0);

    JFrame f = new JFrame();
    f.setSize(300, 300);//from w  ww. j  a  v  a2s . c o  m
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Move the first two rows to the end of the table
    model.moveRow(0, 1, model.getRowCount() - 2);

    JFrame f = new JFrame();
    f.setSize(300, 300);/*from w  ww .j a  va  2 s  .c  o  m*/
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Move the first row to the end of the table
    model.moveRow(0, 0, model.getRowCount() - 1);

    JFrame f = new JFrame();
    f.setSize(300, 300);//from w  ww .  j  a  va 2  s.co  m
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new JFrame();
            frame.add(new TestImage());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();/*from ww  w  . java  2s . com*/
            frame.setVisible(true);
        }
    });
}