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

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(30, 30, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.getContentPane().add(new TryCardLayout());
    aWindow.setVisible(true);
}

From source file:TextLayoutWithCarets.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new TextLayoutWithCarets());
    f.setSize(350, 250);//  www .  j av  a2  s.  c  om
    f.setVisible(true);

}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    AdjustmentListener adjustmentListener = new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
            System.out.println("Adjusted: " + adjustmentEvent.getValue());
        }/*from w  ww .j a  v  a  2 s  .  c  o  m*/
    };
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    oneJScrollBar.addAdjustmentListener(adjustmentListener);

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(oneJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    try {// w  w  w  . j  a v a2 s.  c om
        bg = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
    } catch (Exception ex) {
        System.out.println(ex);
    }

    JPanel tabPanel = new JPanel(new GridBagLayout()) {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(bg, 0, 0, getWidth(), getHeight(), this);
        }

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(400, 300);
        }
    };
    JPanel buttons = new JPanel(new GridLayout(4, 1, 15, 15));
    buttons.setOpaque(false);
    for (int i = 0; i < 4; i++) {
        buttons.add(new JButton("Button"));
    }
    tabPanel.add(buttons);

    JTabbedPane tabPane = new JTabbedPane();
    tabPane.add("Panel with Bachground", tabPanel);

    JFrame frame = new JFrame();
    frame.setContentPane(tabPane);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:MainClass.java

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

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();

    final JButton activate = new JButton("Show");
    frame.add(activate);//w w  w  .  j  a v a  2s .c o m

    frame.pack();
    frame.setVisible(true);

    final Main glass = new Main(frame);
    frame.setGlassPane(glass);

    activate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            glass.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();/*  www  . ja v a 2s .  c  o m*/
            frame.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CUSTOM_CURSOR));
    aWindow.setVisible(true);
}

From source file:SineDraw.java

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

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(p);/*from www .j a  va 2  s  .c o  m*/
    frame.setSize(500, 500);

    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new MyPanel());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();//from   w w w  . ja  va 2 s  .c om
    frame.setVisible(true);
}