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

📄 gauge.java

📁 java语言规范
💻 JAVA
字号:
/* * @(#)Gauge.java	1.2 97/01/14 Jeff Dinkins * * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved. * */package actual; import java.awt.*;import java.applet.*;/* * Gauge - a class that implements a lightweight component * that can be used, for example, as a performance meter. * * Lightweight components can have "transparent" areas, meaning that * you can see the background of the container behind these areas. * */public class Gauge extends Component {      // the current and total amounts that the gauge reperesents  int current = 0;  int total = 100;  // The preferred size of the gauge  int Height = 18;   // looks good  int Width  = 250;  // arbitrary   /**   * Constructs a Gauge   */  public Gauge() {      this(Color.lightGray);  }  /**   * Constructs a that will be drawn uses the   * specified color.   *   * @gaugeColor the color of this Gauge   */  public Gauge(Color gaugeColor) {      setBackground(gaugeColor);  }  public void paint(Graphics g) {      int barWidth = (int) (((float)current/(float)total) * getSize().width);      g.setColor(getBackground());      g.fill3DRect(0, 0, barWidth, getSize().height-2, true);  }  public void setCurrentAmount(int Amount) {      current = Amount;       // make sure we don't go over total      if(current > 100)       current = 100;      repaint();  }  public int getCurrentAmount() {      return current;  }  public int getTotalAmount() {      return total;  }  public Dimension getPreferredSize() {      return new Dimension(Width, Height);  }  public Dimension getMinimumSize() {      return new Dimension(Width, Height);  }}

⌨️ 快捷键说明

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