Java 8일차 Frame, Pannel 테스트

import javax.swing.JButton;
import javax.swing.JFrame;

public class JFrameTest extends JFrame
{
JButton northButton, southButton, eastButton, westButton, centerButton;

public JFrameTest()
{
this.setSize(400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

northButton = new JButton("N");
southButton = new JButton("S");
eastButton = new JButton("E");
westButton = new JButton("W");
centerButton = new JButton("C");

this.add("North", northButton);
this.add("South", southButton);
this.add("East", eastButton);
this.add("West", westButton);
this.add(centerButton);
}

public static void main(String[] args)
{
new JFrameTest();
}
}

result)


















---------------------------------------------------------------------------------------------------------

import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;

public class JFrameTest extends JFrame
{
JButton button1, button2, button3, button4, button5;

public JFrameTest()
{
this.setSize(400, 200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());

button1 = new JButton("1");
button2 = new JButton("2");
button3 = new JButton("3");
button4 = new JButton("4");
button5 = new JButton("5");

this.add(button1);
this.add(button2);
this.add(button3);
this.add(button4);
this.add(button5);
}

public static void main(String[] args)
{
new JFrameTest();
}
}

result)








---------------------------------------------------------------------------------------------------------

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JFrameTest extends JFrame
{
JButton button1, button2, button3, button4, button5;
JPanel panel;

public JFrameTest()
{
this.setSize(400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

button1 = new JButton("1");
button2 = new JButton("2");
button3 = new JButton("3");
button4 = new JButton("4");
button5 = new JButton("5");

panel = new JPanel();

panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(button5);

this.add("South", panel);
}

public static void main(String[] args)
{
new JFrameTest();
}
}

result)


















---------------------------------------------------------------------------------------------------------

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JFrameTest extends JFrame
{
JButton button1, button2, button3, button4;
JPanel panel;
JFrame frame;

public JFrameTest()
{
this.setSize(400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

button1 = new JButton("1");
button2 = new JButton("2");
button3 = new JButton("3");
button4 = new JButton("4");

panel = new JPanel();

panel.add(button1);
panel.add(button2);

this.add("West", button3);
this.add(button4);

this.add("North", panel);

}

public static void main(String[] args)
{
new JFrameTest();
}
}

result)





댓글 없음: