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

public static void main(String[] args) {
    ImagePanel panel = new ImagePanel(new ImageIcon("images/background.png").getImage());

    JFrame frame = new JFrame();
    frame.getContentPane().add(panel);/*  w  w  w . j  ava 2  s  .  c o  m*/
    frame.pack();
    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" });

    Vector data = model.getDataVector();
    Vector row = (Vector) data.elementAt(1);
    // Overwrite the first row with the copy
    Vector firstRow = (Vector) data.elementAt(0);
    for (int i = 0; i < row.size(); i++) {
        firstRow.set(i, row.get(i));//from w  w w.  j a  v a  2s  .co  m
    }

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.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 ava 2 s .  c o m

    f.setSize(300, 300);

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JComponent com = new DraggableComponent();

    JFrame f = new JFrame();

    f.add(com);//w  w  w .  ja  v a2 s  .  com
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:XORRectangles.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new XORRectangles());
    f.setSize(300, 200);//from  www.ja v  a 2  s  . c om
    f.setVisible(true);
}

From source file:Main.java

public static void main(String argv[]) throws Exception {
    JComboBox<Item> comboBox = new JComboBox<Item>(
            new Item[] { new Item("Major", "red"), new Item("Critical", "dark"), new Item("Minor", "green") });
    comboBox.addActionListener(e -> {
        JComboBox<Item> combo = (JComboBox<Item>) e.getSource();
        Item item = (Item) combo.getSelectedItem();
        System.out.println(item.getColor());
    });//  w  w  w  .  j av  a2  s . com
    JFrame frame = new JFrame();
    frame.add(comboBox);
    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Overlap.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new Overlap());
    f.setSize(300, 200);//  w  w  w .  jav  a 2 s.c  o m
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new Main();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();//from w w w. ja  v  a 2  s.c  o  m
    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" });

    Vector data = model.getDataVector();
    Vector row = (Vector) data.elementAt(1);
    // Copy the first column
    int mColIndex = 0;
    List colData = new ArrayList(table.getRowCount());
    for (int i = 0; i < table.getRowCount(); i++) {
        row = (Vector) data.elementAt(i);
        colData.add(row.get(mColIndex));
    }//  w  w w.jav  a2 s  .  c o m
    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[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(600, 400);//  ww  w .ja  va  2 s.co  m
    frame.setVisible(true);
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> {
        System.out.println(frame.getLocation());
    }, 0, 1000, TimeUnit.MILLISECONDS);
}