cheonghan_study
JAVA 기초 _텍스트 본문
import java.awt.event.*;
import java.awt.*;
public class 텍스트 {
public static void main(String[]args) {
Frame fr = new Frame ("텍스트");
fr.setLayout(new FlowLayout());
TextField tf = new TextField("텍스트 필드");
fr.add(tf);
fr.setSize(300,150);
fr.setVisible(true);
fr.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
import java.awt.event.*;
import java.awt.*;
public class 비밀번호 {
public static void main(String[]args) {
Frame fr = new Frame("비밀번호");
fr.setLayout(new FlowLayout());
TextField tf = new TextField("",20);
tf.setEchoChar('*'); //텍스트 박스에 글자를*로 보이게함
fr.add(tf);
Label passwd = new Label("비밀번호");
fr.add(passwd);
fr.setSize(300,150);
fr.setVisible(true);
fr.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}});
}
}
import java.awt.event.*;
import java.awt.*;
public class 로그인 {
public static void main(String[]args) {
Frame fr = new Frame("로그인");
fr.setLayout(new GridLayout(3,1)); //3행 1열로 배치지정
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
p1.setLayout( new FlowLayout() ); //패널에도 배치지정자 지정
p2.setLayout( new FlowLayout() );
p3.setLayout( new FlowLayout() );
Label L1 = new Label("user name");
Label L2 = new Label("passwd");
TextField t1 = new TextField("생일입력",20);
TextField t2 = new TextField("비밀번호",20);
t2.setEchoChar('%');
Button b1 = new Button("확인");
Button b2 = new Button("취소");
p1.add(L1); p1.add(t1);
p2.add(L2); p2.add(t2);
p3.add(b1); p3.add(b2);
fr.add(p1);fr.add(p2);fr.add(p3);
fr.setSize(300,200);
fr.setVisible(true);
fr.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
import java.awt.event.*;
import java.awt.*;
public class 로그인 {
public static void main(String[]args) {
Frame fr = new Frame("");
fr.setLayout(new GridLayout(4,1)); //프레임 먼저 4행1열로 지정
Panel p1 = new Panel(); //각자 패널 1개씩 지정
Panel p2 = new Panel();
Panel p3 = new Panel();
Panel p4 = new Panel();
p1.setLayout( new FlowLayout() ); //순서 주위할것
p2.setLayout( new FlowLayout() );
p3.setLayout( new FlowLayout() );
p4.setLayout( new FlowLayout() );
Label L1 = new Label("아이디");
Label L2 = new Label("비밀번호");
TextField t1 = new TextField("kim",20);
TextField t2 = new TextField("1234",20);
TextField t3 = new TextField("로그인",20);
t2.setEchoChar('*');
Button b1 = new Button("로그인 상태유지");
Button b2 = new Button("IP보안ON");
p1.add(L1); p1.add(t1);
p2.add(L2); p2.add(t2);
p3.add(t3);
p4.add(b1);p4.add(b2);
p1.setBackground(Color.orange); p2.setBackground(Color.cyan); p3.setBackground(Color.green); p4.setBackground(Color.pink);
fr.add(p1);fr.add(p2);fr.add(p3);fr.add(p4);
fr.setSize(300,200);
fr.setVisible(true);
fr.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
public static void main(String[]args) {
Frame fr = new Frame("");
fr.setLayout(new GridLayout(3,1));
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
p1.setLayout(new BorderLayout());
p2.setLayout( new FlowLayout() );
p3.setLayout( new FlowLayout() );
Label L1 = new Label("user name");
Label L2 = new Label("passwd");
TextField t1 = new TextField("생일입력",20);
TextField t2 = new TextField("1234",20);
t2.setEchoChar('%');
Button b1 = new Button("1");
Button b2 = new Button("2");
Button b3 = new Button("3");
Button b4 = new Button("4");
Button b5 = new Button("5");
p3.add(L2); p3.add(t2);
p2.add(L1); p2.add(t1);
p1.add(b1,BorderLayout.WEST);
p1.add(b2,BorderLayout.SOUTH);
p1.add(b3,BorderLayout.EAST);
p1.add(b4,BorderLayout.NORTH);
p1.add(b5);
fr.add(p1); fr.add(p2); fr.add(p3);
fr.setSize(500,400);
fr.setVisible(true);
fr.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
'JAVA' 카테고리의 다른 글
자바_전자계산기 (0) | 2022.06.07 |
---|---|
JAVA 지금까지의 응용 _레이아웃,패널,프레임,텍스트,컬러/textArea (0) | 2022.05.25 |
JAVA기초 _ 그리드 레이아웃 (0) | 2022.05.17 |
JAVA기초_컬러 (0) | 2022.05.06 |
JAVA기초_보더레이아웃 (동서남북 배치) / 창닫기(windowClosing) (0) | 2022.05.06 |