Example usage for javax.swing JFrame setVisible

List of usage examples for javax.swing JFrame setVisible

Introduction

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

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:Main.java

public static void main(String[] argv) {
    Vector rowData = new Vector();
    for (int i = 0; i < 1; i++) {
        Vector colData = new Vector(Arrays.asList("qq"));
        rowData.add(colData);//from   w  w  w .  ja v a  2s .c om
    }

    String[] columnNames = { "a" };

    Vector columnNamesV = new Vector(Arrays.asList(columnNames));

    JTable table = new JTable(rowData, columnNamesV);
    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 {
    Icon leafIcon = new ImageIcon("leaf.gif");
    Icon openIcon = new ImageIcon("open.gif");
    Icon closedIcon = new ImageIcon("closed.gif");

    JTree tree = new JTree();
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setLeafIcon(leafIcon);//from  ww  w.j a v  a  2 s.  c  om
    renderer.setClosedIcon(closedIcon);
    renderer.setOpenIcon(openIcon);

    JFrame f = new JFrame();
    f.add(new JScrollPane(tree));
    f.setSize(300, 300);
    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.addColumn("Col2");

    // Create the first row
    model.insertRow(0, new Object[] { "r1" });

    // Append a row
    model.insertRow(model.getRowCount(), new Object[] { "r5" });

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

From source file:Main.java

public static void main(String[] args) {
    JComboBox<String> box = new JComboBox<>();
    box.addItem("One");
    box.addItem("Two");
    box.addItem("Three");

    box.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                System.out.println(e.getItem());
            }/*from ww  w . ja  v a 2s.  c o m*/
        }
    });
    JFrame frame = new JFrame();
    frame.getContentPane().add(box);
    frame.pack();
    frame.setVisible(true);
}

From source file:Center.java

License:asdf

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.add(new Center());
    f.setSize(300, 300);/*from   w w w .j a v a  2  s.c o  m*/
    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.addColumn("Col2");

    // Create the first row
    model.insertRow(0, new Object[] { "r1" });

    // Insert a row at position p
    int p = 1;// w  w w. j a  v  a  2s. c  o  m
    model.insertRow(p, new Object[] { "r3" });

    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 {
    MyComponent component = new MyComponent();
    JFrame f = new JFrame();

    f.add(component);/* w w w  .  jav  a  2  s  .c  om*/
    f.setSize(300, 300);
    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.addColumn("Col2");

    model.addRow(new Object[] { "v1", "v2" });

    model.addRow(new Object[] { "v1" });

    model.addRow(new Object[] { "v1", "v2", "v3" });

    JFrame f = new JFrame();
    f.setSize(300, 300);//from  w  ww .ja va 2  s. c om
    f.add(new JScrollPane(table));
    f.setVisible(true);

}

From source file:BasicDraw.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new MyComponent());

    frame.setSize(300, 300);/*w w w .ja  va2 s .co m*/
    frame.setVisible(true);
}

From source file:InsertAction.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);
    InsertAction insertSpaceAction = new InsertAction();
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"),
            insertSpaceAction.getValue(Action.NAME));

    component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction);

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