public class JTextTest extends JFrame {JLabel lb, lb1, lb2;JTextField id;JPasswordField passwd;JPanel idPanel, paPanel, loginPanel;JButton b1, b2;JTextArea content; public JTextTest() {super("JText test");setLayout(new FlowLayout());EtchedBorder eborder = new EtchedBorder(); lb = new JLabel("아이디와 패스워드를 입력하세요");lb.setBorder(eborder);add(lb); // 메시지를 프레임에 붙임 idPanel = new JPanel();lb1 = new JLabel..
Swing은 AWT 보다 약간 더 세련 되어졌다.윈도 창의 종료 버튼의 이벤트를 추가하였다.AWT와 마찬가지로 패널을 이용한다. public class JButtonTest extends JFrame {public JButtonTest() {super("Test");JPanel panel = new JPanel();JButton btn = new JButton("Button");panel.add(btn); ImageIcon icon1 = new ImageIcon(".\\src\\1.png"); //기본 이미지ImageIcon icon2 = new ImageIcon(".\\src\\2.png"); //눌렸을 때 이미지JToggleButton tg = new JToggleButton(icon1); //토글버..
안드로이드의 프레임 레이아웃과 유사 (화면 겹침) class CardLayoutTest extends Frame {CardLayout cl = new CardLayout();Panel p[] = new Panel[5];Color color[] = { Color.red, Color.blue, Color.yellow, Color.green,Color.cyan }; public CardLayoutTest(String str) {super(str); setLayout(cl);MouseHandle mh = new MouseHandle();//마우스핸들 객체 생성 for (int i = 0; i < 5; i++) {p[i] = new Panel();p[i].setBackground(color[i]);p[i].add..
class GridLayoutTest extends Frame {public GridLayoutTest(String str) {super(str); Button btn[] = new Button[6]; setLayout(new GridLayout(3,2));for (int i = 0; i < 6; i++) {btn[i] = new Button((i + 1) + "번 버튼");add(btn[i]);}setSize(200, 200);setVisible(true); }} public class GridLayoutMain { public static void main(String[] args) {// TODO Auto-generated method stubnew GridLayoutTest("Grid Layout..
class BorderLayoutTest extends Frame {public BorderLayoutTest(String str) {super(str); setLayout(new BorderLayout());add("North", new Button("북쪽"));add("South", new Button("남쪽"));add("West", new Button("서쪽"));add("East", new Button("동쪽"));add("Center", new Button("중앙")); setSize(200, 200);setVisible(true);}} public class BorderLayoutMain {public static void main(String[] args) {// TODO Auto-gene..
class FlowLayoutTest extends Frame {public FlowLayoutTest(String str) {super(str); FlowLayout fl = new FlowLayout();Button btn[] = new Button[10]; setLayout(fl);for (int i = 0; i < 10; i++) {btn[i] = new Button((i + 1) + "번 버튼");add(btn[i]);}setBounds(100, 100, 200, 200);setVisible(true);}} public class FlowLayoutMain { public static void main(String[] args) {// TODO Auto-generated method stubne..
class MenuTest extends Frame {public MenuTest(String str) {super(str); MenuBar mb = new MenuBar(); //메뉴바 생성Menu file = new Menu("File"); //메뉴 객체 생성MenuItem file_new = new MenuItem("new item");MenuItem file_open = new MenuItem("open");MenuItem file_delete = new MenuItem("delete");MenuItem file_save = new MenuItem("save");//세부 메뉴 생성 file.add(file_new);file.add(file_open);file.add(file_delete);file..
class TextAreaText extends Frame {public TextAreaText(String str) {super(str); Panel p = new Panel();//TextArea txt1 = new TextArea(10,30); //행열 크기 10x30TextArea txt1 = new TextArea("good",15,35); // +@ 초기 문자 셋팅TextField txt2 = new TextField("Hello Java", 20); //txt1.setText("Java World");txt1.setBackground(Color.DARK_GRAY); //영역 배경색 지정txt1.setFont(new Font("굴림체",Font.BOLD,10)); //폰트 지정txt1.setF..