Example usage for javax.swing JFrame show

List of usage examples for javax.swing JFrame show

Introduction

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

Prototype

@Deprecated
public void show() 

Source Link

Document

Makes the Window visible.

Usage

From source file:ListInput.java

public static void main(String[] a) {
    String[] fontNames = new String[] { "Roman", "Times Roman" };
    ListInput lstFontName = new ListInput(fontNames, "Name:");
    lstFontName.setDisplayedMnemonic('n');
    lstFontName.setToolTipText("Font name");
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*w w w .j av  a 2 s .  c  o  m*/
        }
    });
    f.getContentPane().add(lstFontName);
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel panel = (JPanel) frame.getContentPane();
    panel.setLayout(new BorderLayout());
    JTextField field = new JTextField(20);
    Main spinner = new Main();

    panel.add(field, "Center");
    panel.add(spinner, "East");

    Dimension dim = frame.getToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getWidth() / 2, dim.height / 2 - frame.getHeight() / 2);
    frame.pack();//  ww  w.  ja  va2  s  . c  o  m
    frame.show();
}

From source file:BufferedDraw.java

public static void main(String s[]) {

    JFrame f = new JFrame("BufferedShapeMover");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from ww w  .j a  v a2s. c o  m
        }
    });
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(new BufferedDraw(), "Center");

    f.pack();
    f.setSize(new Dimension(550, 250));
    f.show();
}

From source file:SimpleGridBag.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    JPanel p = new JPanel();

    p.setLayout(new GridBagLayout());
    p.add(new JButton("Java"));
    p.add(new JButton("Source"));
    p.add(new JButton("and"));
    p.add(new JButton("Support."));

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  w  w  w.  j  a  v  a  2  s  .  co  m
        }
    };
    f.addWindowListener(wndCloser);

    f.getContentPane().add(p);
    f.setSize(600, 200);
    f.show();
}

From source file:InternalFrameTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Internal Frame Listener");
    Container contentPane = frame.getContentPane();
    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);/*  w ww .ja v a 2  s .  c  om*/
    desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER);
    desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER);
    contentPane.add(desktop, BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.show();
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));
    ButtonGroup group = new ButtonGroup();
    JRadioButton option = new JRadioButton("French Fries", true);
    group.add(option);/*from   w  w w  .ja va  2 s.co m*/
    contentPane.add(option);
    option = new JRadioButton("Onion Rings", false);
    group.add(option);
    contentPane.add(option);
    option = new JRadioButton("Ice Cream", false);
    group.add(option);
    contentPane.add(option);
    frame.setSize(200, 200);
    frame.show();
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    Icon normalIcon = new TriangleIcon(Color.red, TriangleIcon.State.NORMAL);
    Icon pressedIcon = new TriangleIcon(Color.red, TriangleIcon.State.PRESSED);
    Icon rolloverIcon = new TriangleIcon(Color.red, TriangleIcon.State.ROLLOVER);
    JButton b = new JButton("Button", normalIcon);
    b.setPressedIcon(pressedIcon);/*  www .jav  a2s  . c o  m*/
    b.setRolloverIcon(rolloverIcon);
    b.setRolloverEnabled(true);
    contentPane.add(b, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.show();
}

From source file:CardLayoutTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Card Layout");
    final Container contentPane = frame.getContentPane();
    final CardLayout layout = new CardLayout();
    contentPane.setLayout(layout);/*from   w  ww  .j av  a 2s. c o  m*/
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            layout.next(contentPane);
        }
    };
    for (int i = 0; i < 5; i++) {
        String label = "Card " + i;
        JButton button = new JButton(label);
        contentPane.add(button, label);
        button.addActionListener(listener);
    }
    frame.setSize(300, 200);
    frame.show();
}

From source file:AlignY.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Y Alignment");
    JPanel contentPane = (JPanel) frame.getContentPane();

    BoxLayout layout = new BoxLayout(contentPane, BoxLayout.X_AXIS);
    contentPane.setLayout(layout);/*w ww .j  a  va  2 s  .c  o m*/

    JButton button = new JButton("0.0");
    button.setAlignmentY(Component.TOP_ALIGNMENT);
    contentPane.add(button);
    button = new JButton("1.0");
    button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    contentPane.add(button);
    button = new JButton("0.5");
    button.setAlignmentY(Component.CENTER_ALIGNMENT);
    contentPane.add(button);

    frame.setSize(200, 100);
    frame.show();
}

From source file:URLMonitorPanel.java

public static void main(String[] args) throws Exception {
    JFrame frame = new JFrame("URL Monitor");
    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
    Timer t = new Timer();
    String[] u = new String[] { "http://www.java2s.com", "http://www.java2s.com" };

    for (int i = 0; i < u.length; i++) {
        c.add(new URLMonitorPanel(u[i], t));
    }/*  w ww .  ja  v a2s.  c  om*/
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    frame.pack();
    frame.show();
}