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

📄 framedbarmeter.java

📁 书籍"Java_面向事件编程"的附带光盘代码
💻 JAVA
字号:
import objectdraw.*;import java.awt.*;public class FramedBarMeter extends FramedDisplay{         // Space between the frame and the bar    private static final double INSET=2;          // The bar itself    private FilledRect bar;      // Fraction currently being displayed    private double fraction;          // Create frame and bar filling a fraction of the display    public FramedBarMeter( double aFraction,                           double x, double y,                           double width, double height,                           DrawingCanvas canvas) {           super( x, y, width, height, canvas );             fraction = aFraction;                bar = new FilledRect( displayLeft()+INSET,                               displayTop()+INSET,                               (displayWidth()-2*INSET)*fraction,                               displayHeight()-2*INSET, canvas);        bar.setColor(Color.blue);    }          //  Change the fraction of the display filled by the bar    public void setFraction( double aFraction) {        fraction = aFraction;        positionContents();    }      //  Resize and reposition the bar appropriately     protected void positionContents(  ) {            bar.moveTo( displayLeft()+INSET, displayTop()+INSET );        bar.setWidth( (displayWidth()-2*INSET)*fraction );        bar.setHeight( displayHeight()-2*INSET );    }}

⌨️ 快捷键说明

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