Java数据报编程之测试程序[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

    public synchronized void setImage(Image image) {
      if (img != null) {
        img.flush();
        img = null;
      }
      this.img = image;
      if (img != null)
        setSize(image.getWidth(this), image.getHeight(this));
      else
        setSize(0, 0);
      this.repaint();
    }


    public void paintComponent(Graphics g) {
      super.paintComponent(g);
      if (img != null)
        g.drawImage(img, insets.left, insets.top, this);
    }

    public Dimension getPreferredSize() {
      if (img != null) {
        return new Dimension(img.getWidth(this), img.getHeight(this));
      }
      else {
        return new Dimension(320, 160);
      }
    }

    public Dimension getMinimumSize() {
      if (img != null) {
        return new Dimension(img.getWidth(this), img.getHeight(this));
      }
      else {
        return new Dimension(320, 160);
      }
    }

    public Dimension getMaximumSize() {
      if (img != null) {
        return new Dimension(img.getWidth(this), img.getHeight(this));
      }
      else {
        return new Dimension(320, 160);
      }
    }

    public Dimension getSize() {
      if (img != null) {
        return new Dimension(img.getWidth(this), img.getHeight(this));
      }
      else {
        return new Dimension(320, 160);
      }
    }

    private void setSiz() {
      this.setPreferredSize(d);
      this.setMinimumSize(d);
      this.setMaximumSize(d);
      this.setSize(d);
    }
  }
}

本文关键:Java数据报编程之测试程序
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top