import javax.swing.JFrame;Output
public class Test extends JFrame{
public static void main(String[] args) {
//1.JFrame
JFrameウィンドウを作成 = new JFrame("JFrame Test");
//2.ウィンドウを閉じた後、アプリケーションを停止します
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//3.寸法の幅と高さを設定
window.setSize(400,300);
//4.オプション: 中央揃え位置
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("テキストを入力");
//textAreaのサイズを変更します
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.