📄 framedbarmeter.java
字号:
import objectdraw.*;import java.awt.*;// A FramedBarMeter displays a variable length rectangle on a// background framed by a distinct border.public class FramedBarMeter extends FramedDisplay { // Space between the frame and the bar private static final double INSET = BORDER + 2; // The bar itself private FilledRect bar; // Maximum width bar that will fit private double maxWidth; // Create frame and bar filling a fraction of the display public FramedBarMeter( double fraction, double x, double y, double width, double height, DrawingCanvas canvas ) { super( x, y, width, height, canvas ); maxWidth = width - 2*INSET; bar = new FilledRect( x + INSET, y + INSET, maxWidth*fraction, height - 2*INSET, canvas ); bar.setColor(Color.blue); } // Change the fraction of the display filled by the bar public void setFraction( double fraction) { bar.setWidth( maxWidth*fraction ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -