import javax.swing.JFrame;Output
public class Test extends JFrame{
public static void main(String[] args) {
//1. JFrame
JFrame window = new JFrame("JFrame Test");
//2입니다. window를 닫은 후 응용 프로그램을 중지합니다
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//3입니다. 너비와 높이를 설정합니다
window.setSize(400,300);
//4입니다. 선택 사항: centered position
window.setLocationRelativeTo(null);
//5입니다. window
window.setVisible(true);
}
}
import javax.swing.JFrame;Output
import javax.swing.JTextArea;
public class Test extends JFrame{
public static void main(String[] args) {
JFrame frame = new JFrame("JFrame test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
JTextArea jta = new JTextArea("텍스트 입력");
//텍스트 크기 조정
jta.setPreferredSize(new Dimension(400,300));
//가운데에 텍스트 상자 넣기
frame.add(jta);
//남쪽에 버튼 넣기
frame.add(new JButton("erase"),BorderLayout.SOUTH);
//JtextArea와 JButton의 차원을 합산하여 창 크기를 자동으로 계산합니다
frame.pack();
}
}
Please disable your ad blocker and refresh the window to use this website.