/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int i,j;
int[][] arr = new int[n][n];
for(i=0; i<n; i++)
{
arr[i][0] = sc.nextInt();
}
for(i=1; i<n; i++)
{
for(j=1; j<=i; j++)
{
arr[i][j] = arr[i][j-1] - arr[i-1][j-1];
}
}
for(i=0; i<n; i++)
{
for(j=0; j<=i; j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println(" ");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int i,sum=0;
for(i=a; i<=b; i++)
{
if(i%2==0)
{
sum -= i;
}
else
{
sum += i;
}
}
System.out.println(sum);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int i,j,k,sum=0,dec=0;
for(k=a; k<=b; k++)
{
for(i=1; i<=9; i++)
{
System.out.println(k+"*"+i+"="+(k*i));
}
}
}
}
20220918
클래스 : 틀 ( 필드 + 생성자 + 메소드)
객체 : 틀로 찍어낸 물체
import java.util.*;
class Person{
//field 필드
int age;
String name;
//method 메소드 (함수)
void view() {
System.out.println("나이는 "+ age+"이고, 이름은 "+ name+"입니다.");
}
//constructor 생성자 - 객체를 생성할때 필드 값의 초기값을 정해주는 용도
Person(){
age=5000;
name="noname";
}
Person(int a){
age=a;
name="noname";
}
Person(int a, String n){
age=a;
name=n;
}
}
public class Main {
public static void main(String[] args) {
//Scanner sc = new Scanner(System.in);
Person s;
s = new Person();
Person p = new Person(100,"tom");
Person t = new Person(50);
t.view();
p.view();
s.view();
p.age=10; p.name="hello";
s.age=900; s.name="hi";
p.view();
s.view();
//System.out.println("나이는"+ p.age+"이고, 이름은 "+ p.name+"입니다.");
//System.out.println("나이는"+ s.age+"이고, 이름은 "+ s.name+"입니다.");
}
}
*/
/*
class Circle
{
int radius;
String name;
public double getArea()
{
return 3.14*radius*radius;
}
Circle(int r, String n){
radius=r;
name=n;
}
}
class Main{
public static void main(String[] args)
{
// Circle pizza;
// pizza = new Circle();
// pizza.radius = 10;
// pizza.name = "자바피자";
// double area = pizza.getArea();
// System.out.println(pizza.name+"의 면적은"+area);
Circle donut = new Circle(2,"자바도넛");
double area = donut.getArea();
System.out.println(donut.name+"의 면적은"+area);
}
}
*/
/*
import java.util.*;
class Circle {
int radius;
String name;
public Circle() {
radius = 1; name = "";
}
public Circle(int r, String n) {
radius = r; name = n;
}
public double getArea() {
return 3.14*radius*radius;
}
}
class Main{
public static void main(String[]args) {
Circle pizza = new Circle(10, "자바피자");
double area = pizza.getArea();
System.out.println(pizza.name + "의 면적은 " + area);
Circle donut = new Circle();
donut.name = "도넛피자";
area = donut.getArea();
System.out.println(donut.name + "의 면적은 " + area);
}
}
private 다른 클래스에서 접근 할 수 없는 필드, 메소드가 된다
*/
/*
class Song {
private String title;
public Song(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
class Main {
public static void main(String[] args) {
Song mySong = new Song("Nessun Dorma");
Song yourSong = new Song("공주는 잠 못 이루고");
System.out.println("내 노래는 " + mySong.getTitle());
System.out.println("너 노래는 " + yourSong.getTitle());
}
}
*/
/*
class Phone {
private String name, tel;
public Phone(String name, String tel) {
this.name = name;
this.tel = tel;
}
public String getName() { return name; }
public String getTel() { return tel; }
}
class Main {
public static void main(String[] args) {
Phone
}
}
*/
/*
import java.util.*;
class TV {
private String name;
int year;
int size;
public TV(String name,int year,int size)
{
this.name = name;
this.year = year;
this.size = size;
}
public void show()
{
System.out.println(name+"에서 만든 "+year+"년형 "+size+"인치 TV");
}
}
class Main{
public static void main(String [] args)
{
TV myTV = new TV("LG", 2017, 32);
myTV.show();
}
}
*/
/*
import java.util.*;
class Grade {
private int math;
private int science;
private int english;
public Grade(int math,int science,int english)
{
this.math = math;
this.science = science;
this.english = english;
}
public int average()
{
return (math+science+english)/3;
}
}
class Main {
public static void main(String [] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("수학, 과학, 영어 순으로 3개의 정수 입력>>");
Grade me = new Grade(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
System.out.println("평균은 " + me.average());
}
}
*/
/*
import java.util.*;
class Song {
private String title;
private String country;
private String artist;
private int year;
public Song(int year)
{
this(year,"미정","미정","미정");
}
public Song(int year,String title,String country,String artist)
{
this.title = title;
this.country = country;
this.artist = artist;
this.year = year;
}
public void show()
{
System.out.println(year+"년 "+country+"국적의 "+artist+"가 부른 "+title);
}
}
class Main {
public static void main(String [] args)
{
Song mySong = new Song(1978,"Dancing Queen","스웨덴","ABBA");
Song yourSong = new Song(1945);
mySong.show();
}
}
*/
/*
import java.util.*;
class Book {
String title;
String author;
void show() { System.out.println(title + " " + author); }
public Book() {
this("", "");
System.out.println("생성자 호출됨");
}
public Book(String title) {
this(title, "작자미상");
}
public Book(String title, String author) {
this.title = title;
this.author = author;
}
}
class Main {
public static void main(String [] args) {
Book littlePrince = new Book("어린왕자","생텍쥐페리");
Book loveStory = new Book("춘향전");
Book emptyBook = new Book();
loveStory.show();
}
}
*/
/*
class Samp {
int id;
public Samp(int x) {
this.id = x;
}
public Samp() {
this(0);
System.out.println("생성자 호출");
}
}
class ConstructorExample{
//필드
int x;
//메소드
public void setx(int x) { this.x = x; }
public int getx() { return x; }
//생성자
public ConstructorExample() {
}
public static void main(String [] args) {
ConstructorExample a = new ConstructorExample();
int n = a.getx();
}
}
객체 배열을 생성할때는
1. 레퍼런스 배열의 레퍼런스 생성
2. 레퍼런스 배열 생성
3. 객체 생성해서 레퍼런스에 연결
class Person{
String name;
int age;
}
class Main{
public static void main(String[] args) {
// Person p ;//레퍼런스변수 생성
// p = new Person(); //객체 생성
Person[] arr = new Person[10];
for(int i=0;i<arr.length;i++) {
arr[i] = new Person();
}
arr[0].name="민혁";
}
}
*
*/
/*
import java.util.*;
class Circle {
int radius;
public Circle(int radius) {
this.radius = radius;
}
public double getArea() {
return 3.14*radius*radius;
}
}
class Main {
public static void main(String[] args) {
Circle [] c;
c = new Circle[5];
for(int i=0; i<c.length; i++)
c[i] = new Circle(i);
for(int i=0; i<c.length; i++)
System.out.println((int)(c[i].getArea()) + " ");
}
}
*/
/*
import java.util.Scanner;
class Book {
String title,author;
public Book(String title,String author) {
this.title = title;
this.author = author;
}
}
class Main{
public static void main(String[] args) {
Book [] book = new Book[2];
Scanner scanner = new Scanner(System.in);
for(int i=0; i<book.length; i++) {
System.out.print("제목>>");
String title = scanner.nextLine();
System.out.print("저자>>");
String author = scanner.nextLine();
book[i] = new Book(title, author);
}
for(int i=0; i<book.length; i++)
System.out.print("(" + book[i].title + ", " + book[i].author + ")");
}
}
*/
/*
import java.util.*;
class Circle {
private double x, y;
private int radius;
public Circle(double x, double y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public void show() {
System.out.println("("+x+", "+y+")"+radius);
}
}
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Circle c[] = new Circle[3];
for (int i = 0; i < c.length; i++) {
System.out.print("x, y, radius >>");
double x = scanner.nextDouble();
double y = scanner.nextDouble();
int radius = scanner.nextInt();
c[i] = new Circle(x, y, radius);
}
for(int i=0; i<c.length; i++)
c[i].show();
scanner.close();
}
}
import java.util.Scanner;
class Dictionary {
private static String [] kor = { "사랑","아기","돈","미래","희망" };
private static String [] eng = { "love","baby","monry","future", "hope"};
public static String kor2Eng(String word) {
for(int i=0;i<kor.length;i++) {
if(kor[i].equals(word))
return eng[i];
}
return " 저의 사전에 없습니다.";
}
}
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("한영 단어 검색 프로그램입니다.");
while(true) {
System.out.print("한글 단어?");
String name = sc.next();
if(name.equals("그만")) {
return ;
}
else {
System.out.println(name+"는 " +Dictionary.kor2Eng(name));
}
}
}
}
부모클래스 - 자식클래스
슈퍼클래스 - 서브클래스
class Person{
int age;
String name;
}
class Student extends Person{
String school;
char grade;
void speak() {
System.out.println("안녕하세요, 저는 학생입니다.");
System.out.println("나이는 "+age+"살 이고, 이름은 "+name+"입니다");
}
}
class Teacher extends Person{
String school;
String major;
void speak() {
System.out.println("안녕하세요, 저는 선생님입니다.");
System.out.println("나이는 "+age+"살 이고, 이름은 "+name+"입니다");
}
}
class ComTeacher extends Teacher{
}
class Main{
public static void main(String[] args) {
Student s = new Student();
Teacher t = new Teacher();
s.speak();
}
}
*/
/*
import java.util.*;
class Point {
private int x,y;
public void set(int x,int y) {
this.x = x;
this.y = y;
}
public void showPoint() {
System.out.println("(" + x + "," + y + ")");
}
}
class ColorPoint extends Point{
private String color;
void setColor(String color) {
this.color = color;
}
public void showColorPoint() {
System.out.print(color);
showPoint();
}
}
class Main{
public static void main(String [] args) {
Point p = new Point();
p.set(1,2);
p.showPoint();
ColorPoint cp = new ColorPoint ();
cp.set(3,4);
cp.setColor("red");
cp.showColorPoint();
}
}
import java.util.*;
class Pen {
protected int amount;
public int getAmount() { return amount; }
public void setAmount(int amount) { this.amount = amount; }
}
class SharpPencil extends Pen {
private int width;
}
class BallPen extends Pen {
private String color;
public String getColor() { return color; }
public void setColor(String color ) { this.color = color; }
}
class FountainPen extends BallPen {
public void refill(int n) {
amount = n;
}
}
상속-생성자
class A{
int n;
public A() {
System.out.println("A의 기본 생성자");
}
public A(int n) {this.n = n;}
}
class B extends A{
int m;
public B() {
System.out.println("B의 기본 생성자");
}
public B(int m) {
super(20);
this.m = m;
System.out.println("B의 1번 생성자");
}
}
class Main{
public static void main(String[] args) {
//A x = new A(10);
B y = new B(10);
}
}
*/
/*
import java.util.*;
class Point {
private int x,y;
public Point() {
this.x = this.y = 0;
}
public Point(int x,int y) {
this.x = x;this.y = y;
}
public void showPoint() {
System.out.println("(" + x + "," + y + ")");
}
}
class ColorPoint extends Point {
private String color;
public ColorPoint(int x, int y, String color) {
super (x, y);
this.color = color;
}
public void showColorPoint() {
System.out.print(color);
showPoint();
}
}
class Main {
public static void main(String[] args) {
ColorPoint cp = new ColorPoint(5, 6, "blue");
cp.showColorPoint
();
}
}
*/
/*
class TV {
private int size;
public TV(int size) { this.size = size; }
protected int getSize() { return size; }
}
class ColorTV extends TV {
private int Color;
public ColorTV(int size,int Color) {
super(size);
this.Color = Color;
}
public void printProperty() {
System.out.print(getSize()+"인치 "+Color+"컬러");
}
}
class Main {
public static void main(String [] args) {
ColorTV myTV = new ColorTV(32,1024);
myTV.printProperty();
}
}
*/
/*
class TV {
private int size;
public TV(int size) { this.size = size; }
protected int getSize() { return size; }
}
class ColorTV extends TV {
private int Color;
public ColorTV(int size,int Color) {
super(size);
this.Color = Color;
}
protected int getColor() { return Color; }
}
class IPTV extends ColorTV {
private String IP;
public IPTV(String IP,int size,int Color) {
super(size,Color);
this.IP = IP;
}
public void printProperty() {
System.out.print("나의 IPTV는 "+IP+" 주소의 "+getSize()+"인치 "+getColor()+"컬러");
}
class Main {
public static void main(String[]args) {
IPTV iptv = new IPTV("192.1.1.2", 32, 2048);
iptv.printProperty();
}
}
*/
/*
import java.util.*;
class Point {
private int x,y;
public Point(int x, int y) { this.x = x; this.y = y; }
public int getX() { return x; }
public int getY() { return y; }
protected void move(int x, int y) { this.x = x; this.y = y; }
}
class ColorPoint extends Point {
private String Color;
public ColorPoint(int x,int y,String Color) {
super(x,y);
this.Color = Color;
}
public void setXY(int x,int y) {
move (x,y);
}
public void setColor(String Color) {
this.Color = Color;
}
public String toString () {
return Color+"색의 "+"("+ getX() +","+ getY() +")"+"의 점";
}
}
class Main {
public static void main(String[]args) {
ColorPoint cp = new ColorPoint(5, 5, "YELLOW");
cp.setXY(10, 20);
cp.setColor("RED");
String str = cp.toString();
System.out.println(str + "입니다.");
}
}
*/
/*
import java.util.*;
class Point {
private int x,y;
public Point(int x, int y) { this.x = x; this.y = y; }
public int getX() { return x; }
public int getY() { return y; }
protected void move(int x, int y) { this.x = x; this.y = y; }
}
class ColorPoint extends Point {
private String Color;
public ColorPoint() {
super(0,0);
this.Color = "BLACK";
}
public ColorPoint(int x,int y) {
super(x,y);
this.Color = "BLACK";
}
public void setXY(int x,int y) {
move(x,y);
}
public void setColor(String color) {
this.Color = color;
}
public String toString () {
return Color + "색의 " + "("+ getX() + ","+ getY() + ")" + "의 점";
}
}
class Main {
public static void main(String[] args) {
ColorPoint zeroPoint = new ColorPoint();
System.out.println(zeroPoint.toString() + "입니다.");
ColorPoint cp = new ColorPoint(10,10);
cp.setXY(5, 5);
cp.setColor("RED");
System.out.println(cp.toString() + "입니다.");
}
}
*/
/*
import java.util.*;
class Point {
private int x,y;
public Point(int x, int y) { this.x = x; this.y = y; }
public int getX() { return x; }
public int getY() { return y; }
protected void move(int x, int y) { this.x = x; this.y = y; }
}
class Point3D extends Point {
private int z;
public Point3D(int x,int y,int z) {
super(x,y);
this.z = z;
}
public void moveUp() {
z = z+1;
}
public void moveDown() {
z--;
}
public void move(int x, int y,int z) {
super.move(x, y);
this.z = z;
}
public String toString() {
return "("+ getX() + "," + getY() + "," + z +")" + "의 점";
}
}
class Main {
public static void main(String[] args) {
Point3D p = new Point3D(1,2,3);
System.out.println(p.toString() + "입니다.");
p.moveUp();
System.out.println(p.toString() + "입니다.");
p.moveDown();
p.move(10, 10);
System.out.println(p.toString() + "입니다.");
p.move(100, 200, 300);
System.out.println(p.toString() + "입니다.");
}
}
클래스
1. 필드 (변수 ,속성)
2. 메소드 (기능, 행동)
3. 생성자(객체 생성시 필드값 초기화)
추상클래스 : 일부만 작성 == 일부는 작성 x
*/
/*
abstract class Person{
int age;
String name;
void introduce() { //일반 메소드
System.out.println("I'm "+age+"years old. My name is "+name+".");
}
abstract void speak(); //추상메소드 ( 이 클래스를 상속받은 모든 클래스는 이 메소드를 구현)
}
class Student extends Person{
void speak() {
System.out.println("I'm Student.");
}
}
class Teacher extends Person{
void speak() {
System.out.println("I'm Teacher");
}
}
class Main{
public static void main(String[] args) {
Student s = new Student();
}
}
*/
/*
abstract class Calculator {
public abstract int add(int a,int b);
public abstract int subtract(int a,int b);
public abstract double average (int[] a);
}
class GoodCalc extends Calculator {
public int add(int a,int b) {
return a + b;
}
public int subtract(int a,int b) {
return a-b;
}
public double average(int[] a) {
double sum = 0;
for(int i=0; i<a.length; i++)
sum += a[i];
return sum/a.length;
}
}
class Main {
public static void main(String[] args) {
GoodCalc c = new GoodCalc();
System.out.println(c.add(2,3));
System.out.println(c.subtract(2,3));
System.out.println(c.average(new int [] { 2, 3, 4 }));
}
}
*/
/*
import java.util.*;
abstract class Converter {
abstract protected double convert(double src);
abstract protected String getSrcString();
abstract protected String getDestString();
protected double ratio;
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println(getSrcString()+"을 "+getDestString()+"로 바꿉니다.");
System.out.println(getSrcString()+"을 입력하세요>> ");
double val = scanner.nextDouble();
double res = convert(val);
System.out.println("변환 결과: "+res+getDestString()+"입니다.");
}
}
class Won2Dollar extends Converter {
public Won2Dollar(int i) {
}
@Override
protected double convert(double src) {
return src/1200;
}
@Override
protected String getSrcString() {
return "원";
}
@Override
protected String getDestString() {
return "달러";
}
}
class Main{
public static void main(String[] args) {
Won2Dollar toDollar = new Won2Dollar(1200);
toDollar.run();
}
}
*/
/*
import java.util.*;
abstract class Converter {
abstract protected double convert(double src);
abstract protected String getSrcString();
abstract protected String getDestString();
protected double ratio;
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println(getSrcString()+"을 "+getDestString()+"로 바꿉니다.");
System.out.println(getSrcString()+"을 입력하세요>> ");
double val = scanner.nextDouble();
double res = convert(val);
System.out.println("변환 결과: "+res+getDestString()+"입니다.");
}
}
class Km2Mile extends Converter {
public Km2Mile(double i) {
ratio=i;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "Km";
}
protected String getDestString() {
return "mile";
}
}
class Main {
public static void main(String[] args) {
Km2Mile toMile = new Km2Mile(1.6);
toMile.run();
}
}
*/
/*
import java.util.*;
abstract class PairMap {
protected String keyArray [];
protected String ValueArray [];
abstract String get(String key);
abstract void put(String key, String value);
abstract String delete(String key);
abstract int length();
}
class Dictionary extends PairMap {
public Dictionary(int i) {
}
String get(String key) {
return "";
}
void put(String key, String value) {
}
String delete(String key) {
return null;
}
int length() {
return 0;
}
}
class Main {
public static void main(String[] args) {
Dictionary dic = new Dictionary(10);
dic.put("황기태", "자바");
dic.put("이재문", "파이선");
dic.put("이재문", "C++");
System.out.println("이재문의 값은 " + dic.get("이재문"));
System.out.println("황기태의 값은 " + dic.get("황기태"));
dic.delete("황기태");
System.out.println("황기태의 값은 " + dic.get("황기태"));
}
}
*/
/*
import java.util.*;
interface PairMap {
abstract String get(String key);
abstract void put(String key, String value);
abstract String delete(String key, String value);
abstract int length();
}
class Dictionary implements PairMap {
@Override
public String get(String key) {
// TODO Auto-generated method stub
return null;
}
@Override
public void put(String key, String value) {
// TODO Auto-generated method stub
}
@Override
public String delete(String key, String value) {
// TODO Auto-generated method stub
return null;
}
@Override
public int length() {
// TODO Auto-generated method stub
return 0;
}
}
class Main {
public static void main(String[] args) {
Dictionary dic = new Dictionary();
dic.put("황기태", "자바");
dic.put("이재문", "파이선");
dic.put("이재문", "C++");
System.out.println("이재문의 값은 " + dic.get("이재문"));
System.out.println("황기태의 값은 " + dic.get("황기태"));
dic.delete("황기태");
System.out.println("황기태의 값은 " + dic.get("황기태"));
}
}
*/
/*
interface Shape {
final double PI = 3.14;
void draw();
double getArea();
default public void redraw() {
System.out.print("--- 다시 그립니다. ");
draw();
}
}
class Circle implements Shape{
int r;
public Circle(int r) {
this.r = r;
}
public void draw() {
System.out.println("반지름이 " + r + "인 원입니다.");
}
public double getArea() {
return r*r*PI;
}
}
class Main {
public static void main(String [] args) {
Shape donut = new Circle(10);
donut.redraw();
System.out.println("면적은 " + donut.getArea());
}
}
interface MouseDriver {
final int BUTTONS = 3;
//int VERSION;
void move();
public int click();
int out();
void drag();
default void drop() {
System.out.println("drop");
}
}
GUI : 그림으로 보여지는것
컨테이너 container : 종이 판 (다른 것들을 포함한다)
컴포넌트 component : 스티커 (컨테이너 위에 올라간다)
import java.awt.*;
import javax.swing.*;
class Main extends JFrame{
public Main() {
setTitle("example1"); // 창 제목 정하기 (필수아님)
setSize(500, 300); //가로500, 세로 300으로 크기 셋팅 (필수)
Container c = getContentPane(); // c = 현재 배경
c.setLayout(new FlowLayout()); //레이아웃 설정 (나중에)
JButton b = new JButton("버튼"); //버튼 생성
c.add(b); //버튼 추가
JLabel la = new JLabel("레이블컴포넌트입니다");
c.add(la);
setVisible(true); // 프레임이 보이게 설정 (필수)
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class Main extends JFrame{
public Main() {
setTitle("ContentPane과 JFrame");
setSize(500,300);
Container c = getContentPane();
//c.setLayout(new FlowLayout());
c.setLayout(new BorderLayout(5,10));
c.setBackground(Color.black); //배경색 설정
JButton b = new JButton("OK");
b.setBackground(Color.white);
b.setForeground(Color.black);
c.add(b,BorderLayout.NORTH);
// JButton b1 = new JButton("Cancel");
// b1.setBackground(Color.white);
// b1.setForeground(Color.black); //전경색 (글자색) 설정
// c.add(b1, BorderLayout.CENTER);
JButton b2 = new JButton("Ignore");
b2.setForeground(Color.black);
c.add(b2, BorderLayout.CENTER);
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.setBackground(Color.black);
c.add(p,BorderLayout.EAST);
JButton b3 = new JButton("Cancel");
p.add(new JButton("Cancel"));
p.add(b3);
b3.setForeground(Color.blue);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class Main extends JFrame{
public Main() {
setTitle("Let's study Java");
setSize(400,200);
Container c = getContentPane();
c.setLayout(new BorderLayout(5,7));
JButton b = new JButton("Center");
c.add(b, BorderLayout.CENTER);
JButton b1 = new JButton("East");
c.add(b1, BorderLayout.EAST);
JButton b2 = new JButton("West");
c.add(b2, BorderLayout.WEST);
JButton b3 = new JButton("North");
c.add(b3, BorderLayout.NORTH);
JButton b4 = new JButton("South");
c.add(b4, BorderLayout.SOUTH);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("GridLayour Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(4, 2);
grid.setVgap(5);
Container c = getContentPane();
c.setLayout(grid);
c.add(new JLabel(" 이름"));
c.add(new JTextField(""));
c.add(new JLabel(" 학번"));
c.add(new JTextField(""));
c.add(new JLabel(" 학과"));
c.add(new JTextField(""));
c.add(new JLabel(" 과목"));
c.add(new JTextField(""));
setSize(300, 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("Null Container Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
JLabel la = new JLabel("Hello, Press Buttons!");
la.setLocation(130, 50);
la.setSize(200, 20);
c.add(la);
for(int i=1; i<=9; i++) {
JButton b = new JButton(Integer.toString(i));
//***********************
//random
//
//************************
int x = (int) Math.random()*200;
int y = (int) Math.random()*300;
b.setLocation(x, y);
b.setSize(50,20);
c.add(b);
}
setSize(300, 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("Ten Color Buttons Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(1, 10);
Container c = getContentPane();
c.setLayout(grid);
Color[] clr = {Color.red, Color.orange, Color.yellow, Color.green, Color.cyan, Color.blue, Color.magenta, Color.darkGray, Color.pink, Color.gray };
for(int i=0; i<10; i++) {
JButton b = new JButton(Integer.toString(i));
b.setBackground(clr[i]);
b.setSize(50,20);
c.add(b);
}
setSize(600, 250);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("4x4 Color Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(4, 4);
Container c = getContentPane();
c.setLayout(grid);
Color[] clr = {Color.red,Color.orange,Color.yellow,Color.green,Color.cyan,Color.blue,Color.magenta,Color.darkGray,Color.pink,Color.gray,Color.red,Color.orange,Color.yellow,Color.green,Color.cyan,Color.blue};
for(int i=0; i<16; i++) {
JButton b = new JButton(Integer.toString(i));
b.setBackground(clr[i]);
b.setSize(50,20);
c.add(b);
}
setSize(600, 250);
setVisible(true);
}
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);
}
}
*/