ウインドウの内容
ウインドウの内容
1 import javax.swing.*;
2 import java.awt.*;
3
4 public class Sample3
5 {
6 public static void main(String[] args)
7 {
8 JFrame f;
9 Container cp;
10 JPanel p;
11
12 f = new JFrame();
13 f.setVisible(true);
14 f.setTitle("swing");
15 f.setSize(200, 300);
16 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17 cp = f.getContentPane();
18 p = new JPanel();
19 cp.add(p);
20 }
21 }
1 import javax.swing.*;
2 import java.awt.*;
3
4 public class Sample4 extends JPanel
5 {
6 public void paintComponent(Graphics g)
7 {
8 g.drawRect(50,50,100,150);
9 }
10 }
1 public static void main(String[] args)
2 {
3 JFrame f;
4 Container cp;
5 JPanel p;
6
7 f = new JFrame();
8 f.setVisible(true);
9 f.setTitle("swing");
10 f.setSize(200, 300);
11 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
12 cp = f.getContentPane();
13 p = new Sample4();
14 cp.add(p);
15 }
ウインドウの内容 (最終更新日時 2009-11-27 01:51:09 更新者 masahiko)