/*import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("Let's study Java");
setSize(400, 200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("BorderLayout");
setSize(400, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout(5, 7));
c.add(new JButton("North"), BorderLayout.NORTH);
c.add(new JButton("South"), BorderLayout.SOUTH);
c.add(new JButton("East"), BorderLayout.EAST);
c.add(new JButton("West"), BorderLayout.WEST);
c.add(new JButton("Center"), BorderLayout.CENTER);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
class myJButton extends JButton{
myJButton(String label, Color c)
{
super(label);
setBackground(c);
}
}
public class Main extends JFrame {
public Main() {
setTitle("Ten Color Buttons Frame");
setVisible(true);
setSize(600, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
GridLayout grid = new GridLayout(1, 10);
c.setLayout(grid);
c.add(new myJButton("0",Color.red));
c.add(new myJButton("1",Color.orange));
c.add(new myJButton("2", Color.yellow));
c.add(new myJButton("3", Color.green));
c.add(new myJButton("4", Color.cyan));
c.add(new myJButton("5", Color.BLUE));
c.add(new myJButton("6", Color.magenta));
c.add(new myJButton("7", Color.DARK_GRAY));
c.add(new myJButton("8", Color.pink));
c.add(new myJButton("9", Color.gray));
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
class myJButton extends JButton {
myJButton(String Label, Color c) {
super(Label);
setBackground(c);
}
}
public class Main extends JFrame {
public Main() {
setTitle("4X4 Color Frame");
setVisible(true);
setSize(800, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
GridLayout grid = new GridLayout(4, 4);
c.setLayout(grid);
c.add(new myJButton("0", Color.red));
c.add(new myJButton("1", Color.orange));
c.add(new myJButton("2", Color.yellow));
c.add(new myJButton("3", Color.green));
c.add(new myJButton("4", Color.cyan));
c.add(new myJButton("5", Color.blue));
c.add(new myJButton("6", Color.magenta));
c.add(new myJButton("7", Color.gray));
c.add(new myJButton("8", Color.pink));
c.add(new myJButton("9", Color.LIGHT_GRAY));
c.add(new myJButton("10", Color.white));
c.add(new myJButton("11", Color.DARK_GRAY));
c.add(new myJButton("12", Color.black));
c.add(new myJButton("13", Color.orange));
c.add(new myJButton("14", Color.blue));
c.add(new myJButton("15", Color.magenta));
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("Random Labels");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
for(int i=0; i<20; i++) {
JButton la = new JButton(Integer.toString(i));
int x = (int)(Math.random()*200) + 50;
int y = (int)(Math.random()*200) + 50;
la.setLocation(x, y);
la.setSize(10, 10);
la.setBackground(Color.blue);
c.add(la);
la.setOpaque(true);
}
setVisible(true);
setSize(300, 300);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
class myJButton extends JButton {
myJButton(String Label, Color c) {
super(Label);
setBackground(c);
}
myJButton(String Label) {
super(Label);
}
}
public class Main extends JFrame {
public Main() {
setTitle("계산기 프레임");
setSize(400, 400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container d = getContentPane();
Panel a = new Panel();
Panel b = new Panel();
GridLayout grid = new GridLayout(4, 4);
b.setLayout(grid);
Panel c = new Panel();
d.setLayout(new BorderLayout());
a.add(new JLabel("수식입력"));
a.add(new JTextField(20));
d.add(a, BorderLayout.NORTH);
b.add(new myJButton("0"));
b.add(new myJButton("1"));
b.add(new myJButton("2"));
b.add(new myJButton("3"));
b.add(new myJButton("4"));
b.add(new myJButton("5"));
b.add(new myJButton("6"));
b.add(new myJButton("7"));
b.add(new myJButton("8"));
b.add(new myJButton("9"));
b.add(new myJButton("CE"));
b.add(new myJButton("계산"));
b.add(new myJButton("+", Color.cyan));
b.add(new myJButton("-", Color.cyan));
b.add(new myJButton("x", Color.cyan));
b.add(new myJButton("/", Color.cyan));
d.add(b, BorderLayout.CENTER);
c.add(new JLabel("계산결과"));
c.add(new JTextField(20));
d.add(c, BorderLayout.SOUTH);
a.setBackground(Color.gray);
c.setBackground(Color.yellow);
}
public static void main(String[] args) {
new Main();
}
}*/
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("여러 개의 패널을 가진 프레임");
setSize(700, 700);
setVisible(true);
Container d = getContentPane();
Panel a = new Panel();
//a.setLayout(new FlowLayout());
Panel c = new Panel();
//c.setLayout(new FlowLayout());
d.setLayout(new BorderLayout());
a.add(new JButton("열기"));
a.add(new JButton("닫기"));
a.add(new JButton("나가기"));
a.setBackground(Color.gray);
d.add(a, BorderLayout.NORTH);
Panel b = new Panel();
d.add(b, BorderLayout.CENTER);
b.setBackground(Color.white);
b.setLayout(null);
for(int i=0; i<10; i++) {
int x = (int)(Math.random()*700 + 0);
int y = (int)(Math.random()*700 + 0);
JLabel la = new JLabel("*");
la.setLocation(x, y);
la.setSize(10, 10);
b.add(la);
la.setOpaque(true);
}
c.add(new JButton("Word Input"));
c.add(new JTextField(20));
d.add(c, BorderLayout.SOUTH);
}
public static void main(String[] args) {
new Main();
}
}