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[] args) {
    JComboBox<String> my = new JComboBox<>(new String[] { "HELLO WORLD", "java2s.com" });
    JFrame frame = new JFrame("");
    frame.add(my);/*from   ww w .  j  a va 2  s  . c o m*/
    frame.pack();
    frame.setVisible(true);
    my.setSelectedIndex(1);
}

From source file:Main.java

public static final void main(String[] args) throws Exception {
    JFrame frame = new Main();
    frame.pack();//from  w w w. j  a va 2 s.  com
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame x = new JFrame("Look at me");
    x.setSize(200, 300);/*from  w  w w  .  j  a v a2 s  .c  o m*/
    x.setVisible(true);
    x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FileOutputStream f;
    try {
        f = new FileOutputStream("Test.xml");
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(f));
        e.writeObject(x);
        e.close();
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(400, 400);/* w  w w.j a  v a  2 s  .com*/
    frame.setVisible(true);
    String[] list = { "1", "2", "3", "4", };
    JComboBox<String> comb = new JComboBox<>(list);
    final JPopupMenu pop = new JPopupMenu();
    pop.add(comb);
    frame.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            System.out.println("mousePressed");
            pop.show(e.getComponent(), e.getX(), e.getY());
        }
    });
}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed X"), "none");

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

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("a");
    component.addFocusListener(new MyFocusListener());

    JFrame f = new JFrame();
    f.add(component);/* w  w  w. j  a v  a  2 s  . c o m*/
    f.pack();
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.add(new Main());

    f.setSize(300, 300);/*from   w  w  w. j  av a2  s  . c  o  m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

    JFrame f = new JFrame();
    f.add(component);//from  w  w w .j a v  a  2s  .com

    f.setSize(300, 300);

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed -"), "actionName");

    JFrame f = new JFrame();
    f.add(component);//from  w w  w  . ja v  a  2s.  c  om

    f.setSize(300, 300);

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed a"), "actionName");

    JFrame f = new JFrame();
    f.add(component);/*from  w  w w.  ja  va  2  s . co m*/

    f.setSize(300, 300);

    f.setVisible(true);

}