📄 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 { private Text message; // The message displayed private Location frameCenter; // Where message belongs // 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 frameCenter = new Location( x + width/2, y + height/2 ); message = new Text ( contents, x, y, canvas ); message.setColor( Color.white ); positionContents(); } // Position the message to center it in the frame private void positionContents() { message.moveTo( frameCenter ); message.move( -message.getWidth()/2, -message.getHeight()/2 ); } // Change the font size used public void setTextSize( int size ) { message.setFontSize( size ); positionContents(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -