- 자바 스윙에서 기본이 되는 Frame을 만들어보자.
메인 메서드에서 바로 Frame을 만들 수 있지만 앞으로도 계속 프레임 클래스를 호출할 것이므로 처음부터 빼놓자.
public class Main01 {
public static void main(String[] args) {
new Myframe();
}
}
package learningSwingByYoutube;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class Myframe extends JFrame{
public Myframe() {
this.setTitle("Jthis title goes here");
this.setSize(420, 420);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setResizable(true);
this.setVisible(true);
this.setLocation(300, 400);
ImageIcon image1 = new ImageIcon("image1.jpg");
this.setIconImage(image1.getImage());
this.getContentPane().setBackground(Color.GREEN);
}
}
ImageIcon image1 = new ImageIcon("image1.jpg");
this.setIconImage(image1.getImage());