📄 framedtext.java
字号:
import objectdraw.*;import java.awt.*;// A FramedText object displays a specified text message on a// background framed by a distinct border.public class FramedText extends FramedDisplay { // Colors used for the text private static final Color TEXTCOLOR = Color.gray; private static final Color HIGHLIGHTCOLOR = Color.red; protected Text message; // The message displayed // Create a FramedText object displaying the text 'contents' // at the position and with the dimensions specified. public FramedText( String contents, double x, double y, double width, double height, DrawingCanvas canvas) { // construct the frame super( x, y, width, height, canvas); // Construct and appropriately position the message message = new Text ( contents, x, y, canvas); message.setColor( TEXTCOLOR ); positionContents(); } // Position the message to center it in the frame private void positionContents() { message.moveTo( displayLeft(), displayTop() ); message.move( (displayWidth()-message.getWidth())/2, (displayHeight()-message.getHeight()) /2 ); } // Change the font size used public void setTextSize( int size) { message.setFontSize( size ); positionContents(); } // Highlight the display by changing the text color public void highlight() { message.setColor( HIGHLIGHTCOLOR ); } // Restore the standard text color public void unHighlight() { message.setColor( TEXTCOLOR ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -