📄 framedbarmeter.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 + -