티스토리 뷰
import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; class MyFrame3 extends JFrame{ JPanel panel = new JPanel(); public MyFrame3() { add(panel); panel.setBackground(Color.BLUE); setSize(300,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } public class 패널1 { public static void main(String[] args) { new MyFrame3(); } }
import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; class MyFrame4 extends JFrame{ JLabel label1 = new JLabel(); JLabel label2 = new JLabel("레이블2"); public MyFrame4(){ setLayout( new FlowLayout() ); label1.setText("레이블1"); add( label1 ); add( label2 ); setSize(300,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } public class 레이블1 { public static void main(String[] args) { new MyFrame4(); } }
import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; class MyFrame5 extends JFrame{ JButton b1 = new JButton(); JButton b2 = new JButton("버튼2"); public MyFrame5(){ setLayout(new FlowLayout()); // 배치관리자 클래스 b1.setText("버튼1"); // 이름 지정 b1.setEnabled(false); // 누를 수 없게 지정 add(b1); // Frame에 추가 add(b2); setSize(500,500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } } public class 버튼1 { public static void main(String[] args) { new MyFrame5(); } }
'JAVA > PRIMER' 카테고리의 다른 글
[JAVA] GUI - 이벤트 (0) | 2018.04.19 |
---|---|
[JAVA] GUI - 배치관리자 (0) | 2018.04.19 |
[JAVA] GUI - JFrame (0) | 2018.04.19 |
[JAVA] 파일입출력 - FileInputStream, FileOutputStream (0) | 2018.04.19 |
[JAVA] 파일입출력 - BufferedReader, BufferedWriter (0) | 2018.04.19 |
댓글