CS Study/디자인패턴
2021.12.09_컴포짓패턴04.자바와스프링에서찾아보는패턴
KyeongMin
2021. 12. 9. 21:41
728x90
반응형
package me.whiteship.designpatterns._02_structural_patterns._08_composite._03_java;
import javax.swing.*;
public class SwingExample {
public static void main(String[] args) {
JFrame frame = new JFrame();
JTextField textField = new JTextField();
textField.setBounds(200, 200, 200, 40);
frame.add(textField);
JButton button = new JButton("click");
button.setBounds(200, 100, 60, 40);
button.addActionListener(e -> textField.setText("Hello Swing"));
frame.add(button);
frame.setSize(600, 400);
frame.setLayout(null);
frame.setVisible(true);
}
}
- 예제 코드 swing이라는 라이브러리
- 데스크탑용 앱 만드는것dlsep
- 위를 보면 JFram, JTextField, JButton을 보면됨
- 이 세개가 컴포넌트에서 만남
728x90
반응형