welcome: please sign in
location: "ウインドウの内容"の差分
4と5のリビジョン間の差分
2009-11-27 01:48:19時点のリビジョン4
サイズ: 556
編集者: masahiko
コメント:
2009-11-27 01:51:09時点のリビジョン5
サイズ: 1078
編集者: masahiko
コメント:
削除された箇所はこのように表示されます。 追加された箇所はこのように表示されます。
行 31: 行 31:

 {{{#!java
 import javax.swing.*;
 import java.awt.*;
 
 public class Sample4 extends JPanel
 {
  public void paintComponent(Graphics g)
  {
   g.drawRect(50,50,100,150);
  }
 }
 }}}

 {{{#!java
 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);
 }
 }}}

ウインドウの内容

  • 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                 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         }
    

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