frameddisplay.java

来自「书籍"Java_面向事件编程"的附带光盘代码」· Java 代码 · 共 49 行

JAVA
49
字号
import objectdraw.*;import java.awt.*;// A FramedDisplay is a composite graphic intended to serve// as a frame in which a program can display various forms// of information.public class FramedDisplay {        protected static final int BORDER = 3;    // Border thickness    private static final int ROUNDNESS = 5; // Corner roundess        // Colors used for the frame    private static final Color BORDERCOLOR = Color.gray;    private static final Color HIGHLIGHTCOLOR = Color.red;        private FilledRoundedRect body;            // The background    private FilledRoundedRect border;        // The border        // Create the display area's background and border and set    // their colors appropriately    public FramedDisplay( double x, double y,                          double width, double height,                          DrawingCanvas canvas ) {                border = new FilledRoundedRect( x, y,                                        width, height,                                        ROUNDNESS, ROUNDNESS,                                        canvas );                body = new FilledRoundedRect( x + BORDER, y + BORDER,                                      width - 2*BORDER, height - 2*BORDER,                                      ROUNDNESS, ROUNDNESS,                                      canvas );                border.setColor( BORDERCOLOR );    }        // Change the border's color to make it stand out    public void highlight(  ) {        border.setColor( HIGHLIGHTCOLOR );    }        // Restore the standard border color    public void unHighlight( ) {        border.setColor( BORDERCOLOR );    }    }

⌨️ 快捷键说明

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