목차
객체추출

컴포넌트
- GUI 기반 구성요소
- 일반 컴포넌트 : 버튼, 입력상자 등
- Container 컴포넌트 : Frame, Panel
- 구조

코드 예시
package mycome.mytest;
import java.awt.Frame;
import java.awt.Button;
import java.awt.Color;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 메모리에 Frame 객체 생성
Frame f = new Frame();
// 윈도우 사이즈 설정
f.setSize(800, 600);
// 백그라운드 컬러 설정
Color bgcolor = new Color(195, 200, 234);
f.setBackground(bgcolor);
// 버튼 만들기
Button center = new Button("Login");
Button west = new Button("West");
Button east = new Button("East");
Button north = new Button("North");
Button south = new Button("South");
// 만들고 버튼 붙이기
f.add(center, "Center");
f.add(west, "West");
f.add(east, "East");
f.add(north, "North");
f.add(south, "South");
// 윈도우 띄우기
f.setVisible(true);
}
}
그래픽 기술(GUI)
- 저급 그래픽
- 고급 그래픽 : 사용하기 간단하나 제약 사항이 있음.
- 컴포넌트
- 일반 컴포넌트
- 컨테이너 컴포넌트 : 하위 컴포넌트, frame, Pannel
- Frame : window(process) = 1: 1
- LayoutManager : BorderLayout, GridLayout 등
- Button1
- Button2
- 컴포넌트
- 예제 코드
package mycome.mytest;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Button;
import java.awt.Color;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 메모리에 Frame 객체 생성
Frame f = new Frame();
// 윈도우 사이즈 설정
f.setSize(350, 200);
// 백그라운드 컬러 설정
Color bgcolor = new Color(255, 255, 255);
f.setBackground(bgcolor);
// GridLayout
f.setLayout(new GridLayout(3,1));
// 타이틀
Panel title = new Panel();
Label lab_lscreen = new Label("로그인 화면");
title.add(lab_lscreen);
// 로그인 아이디
Panel id_screen = new Panel();
id_screen.setLayout(new GridLayout(2,2));
Label lab_id = new Label("아이디");
TextField tf_id = new TextField();
Label lab_password = new Label("패스워드");
TextField tf_password = new TextField();
id_screen.add(lab_id);
id_screen.add(tf_id);
id_screen.add(lab_password);
id_screen.add(tf_password);
// 로그인 / 취소 버튼 만들기
Panel login_buttons = new Panel(); // container
Button btnlogin = new Button("로그인");
Button btnCancel = new Button("취소");
login_buttons.add(btnlogin);
login_buttons.add(btnCancel);
f.add(title);
f.add(id_screen );
f.add(login_buttons);
f.setVisible(true);
}
}

'웹 애플리케이션 > 자바' 카테고리의 다른 글
1_9 자바 객체지향(형변환) (0) | 2023.03.17 |
---|---|
1_8 자바 클래스 간 관계(상속) (0) | 2023.03.16 |
1_6 자바 UMLet 설치 및 활용 (0) | 2023.03.15 |
1_5 자바 객체지향 실습(회원관리 프로그램) (0) | 2023.03.15 |
1_4 자바 객체지향 실습(성적관리 프로그램) (0) | 2023.03.15 |
객체추출

컴포넌트
- GUI 기반 구성요소
- 일반 컴포넌트 : 버튼, 입력상자 등
- Container 컴포넌트 : Frame, Panel
- 구조

코드 예시
package mycome.mytest;
import java.awt.Frame;
import java.awt.Button;
import java.awt.Color;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 메모리에 Frame 객체 생성
Frame f = new Frame();
// 윈도우 사이즈 설정
f.setSize(800, 600);
// 백그라운드 컬러 설정
Color bgcolor = new Color(195, 200, 234);
f.setBackground(bgcolor);
// 버튼 만들기
Button center = new Button("Login");
Button west = new Button("West");
Button east = new Button("East");
Button north = new Button("North");
Button south = new Button("South");
// 만들고 버튼 붙이기
f.add(center, "Center");
f.add(west, "West");
f.add(east, "East");
f.add(north, "North");
f.add(south, "South");
// 윈도우 띄우기
f.setVisible(true);
}
}
그래픽 기술(GUI)
- 저급 그래픽
- 고급 그래픽 : 사용하기 간단하나 제약 사항이 있음.
- 컴포넌트
- 일반 컴포넌트
- 컨테이너 컴포넌트 : 하위 컴포넌트, frame, Pannel
- Frame : window(process) = 1: 1
- LayoutManager : BorderLayout, GridLayout 등
- Button1
- Button2
- 컴포넌트
- 예제 코드
package mycome.mytest;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Button;
import java.awt.Color;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 메모리에 Frame 객체 생성
Frame f = new Frame();
// 윈도우 사이즈 설정
f.setSize(350, 200);
// 백그라운드 컬러 설정
Color bgcolor = new Color(255, 255, 255);
f.setBackground(bgcolor);
// GridLayout
f.setLayout(new GridLayout(3,1));
// 타이틀
Panel title = new Panel();
Label lab_lscreen = new Label("로그인 화면");
title.add(lab_lscreen);
// 로그인 아이디
Panel id_screen = new Panel();
id_screen.setLayout(new GridLayout(2,2));
Label lab_id = new Label("아이디");
TextField tf_id = new TextField();
Label lab_password = new Label("패스워드");
TextField tf_password = new TextField();
id_screen.add(lab_id);
id_screen.add(tf_id);
id_screen.add(lab_password);
id_screen.add(tf_password);
// 로그인 / 취소 버튼 만들기
Panel login_buttons = new Panel(); // container
Button btnlogin = new Button("로그인");
Button btnCancel = new Button("취소");
login_buttons.add(btnlogin);
login_buttons.add(btnCancel);
f.add(title);
f.add(id_screen );
f.add(login_buttons);
f.setVisible(true);
}
}

'웹 애플리케이션 > 자바' 카테고리의 다른 글
1_9 자바 객체지향(형변환) (0) | 2023.03.17 |
---|---|
1_8 자바 클래스 간 관계(상속) (0) | 2023.03.16 |
1_6 자바 UMLet 설치 및 활용 (0) | 2023.03.15 |
1_5 자바 객체지향 실습(회원관리 프로그램) (0) | 2023.03.15 |
1_4 자바 객체지향 실습(성적관리 프로그램) (0) | 2023.03.15 |