welcome: please sign in
location: "ウインドウの内容"の差分
5と6のリビジョン間の差分
2009-11-27 01:51:09時点のリビジョン5
サイズ: 1078
編集者: masahiko
コメント:
2009-11-27 01:53:42時点のリビジョン6
サイズ: 881
編集者: masahiko
コメント:
削除された箇所はこのように表示されます。 追加された箇所はこのように表示されます。
行 46: 行 46:
 public static void main(String[] args)
 {
  JFrame f;
  Container cp;
  JPanel p;
  
  f = new JFrame();
  f.setVisible(true);
  f.setTitle("swing");
  f.setSize(200, 300);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  cp = f.getContentPane();
  p = new Sample4();
  cp.add(p);
 }
 public static void main(String[] args)
 {
  ...
  Sample4 p;
  ...
  p = new Sample4();
  ...
 }

ウインドウの内容

  • swing04.png

       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  }
    
  • swing05.png

  • swing06.png

       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         ...
       4         Sample4 p;      
       5         ...
       6         p = new Sample4();
       7         ...
       8  }
    

ウインドウの内容 (最終更新日時 2010-12-13 02:46:25 更新者 masahiko)