昨天在和淺雨大聊天室時,問到的問題..寫了個簡單的例子..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import javax.swing.JFrame; import javax.swing.JLabel;
class TestFrame { public static void main(String[] args) { new HelloWorld().setVisible(true); } }
class HelloWorld extends JFrame { HelloWorld() { super("這是標題");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(780,500); setResizable(false); setLocationRelativeTo(null);
JLabel myLabel = new JLabel("這是文字"); myLabel.setLocation(100,100); getContentPane().add(myLabel); } }
|