⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picture.java

📁 这是一个买卖系统,一个模拟的系统,根据下订单,看订单,买,等功能
💻 JAVA
字号:
package Clients;

import java.awt.*;
import java.awt.geom.*;
import javax.swing.ImageIcon;

class Picture extends Canvas
{
  private static final long serialVersionUID = 1;
  private int   width      = 260;
  private int   height     = 260;
  private Image thePicture = null;

  public Picture()
  {
    setSize( width, height );
  }
  
  public Picture(int aWidth, int aHeight)
  {
    width = aWidth;
    height= aHeight;
    setSize( width, height );
  }

  public void set( ImageIcon ic )
  {
    thePicture = ic.getImage();         // Image to be drawn
    repaint();
  }
    
  public void clear()
  {
    thePicture = null;                  // clear picture
    repaint();                          // Force repaint
  }

  public void paint( Graphics g )       // When 'Window' is first
  {                                     //  shown or damaged
    drawImage( (Graphics2D) g );
  }
  
  public void update( Graphics g )      // Called by repaint
  {                                     //
    drawImage( (Graphics2D) g );        // Draw picture
  }

  /**
    * Draw the picture
    * First set the area to white and then 
    *  draw the image 
    */

  public void drawImage( Graphics2D g )
  {
    setSize( width, height );
    g.setPaint( Color.white );
    g.fill( new Rectangle2D.Double( 0, 0, width, height ) );
    if ( thePicture != null )
    {
      g.drawImage(thePicture, 0, 0, null);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -