From 97a2273543f5596532f2336a264e3f6eea678859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E6=89=BF=E6=89=AC?= <2923616405@qq.com> Date: Thu, 15 Aug 2019 16:29:16 +0800 Subject: [PATCH] Update --- .idea/workspace.xml | 37 ++++++++-------- .../DrawStringTest.java" | 43 +++++++++++++++++++ 2 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 "src/AWT\347\273\230\345\233\276/DrawStringTest.java" diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 66afe63..be194d7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,8 @@ - - + + - + - - @@ -320,14 +320,8 @@ - - - - 1561385104652 - 1561432271697 @@ -665,7 +659,14 @@ - diff --git "a/src/AWT\347\273\230\345\233\276/DrawStringTest.java" "b/src/AWT\347\273\230\345\233\276/DrawStringTest.java" new file mode 100644 index 0000000..68d2229 --- /dev/null +++ "b/src/AWT\347\273\230\345\233\276/DrawStringTest.java" @@ -0,0 +1,43 @@ +// >= JDK 1.8 +// encoding:utf-8 +// @software:IntelliJ IDEA +// @user:彭友聪 +// @date:2019/08/15 +// @time:下午 4:18 +// @project:IDEA_JAVA +// @file:DrawStringTest.java +// @Author:御承扬 +//@E-mail:2923616405@qq.com + +package AWT绘图; + +import javax.swing.*; +import java.awt.*; + +public class DrawStringTest extends JFrame { + static class CanvasTest extends Canvas { + CanvasTest() { + } + + public final void paint(Graphics g){ + super.paint( g ); + Graphics2D g2 = (Graphics2D) g; + g2.setColor( Color.BLUE ); + Font font = new Font( "楷体", Font.BOLD, 16 ); + g2.setFont( font ); + g2.drawString( "Done is better than perfect.", 20, 30 ); + g2.drawString( "——比完美更重要是完成。", 60, 60 ); + } + } + private DrawStringTest() { + this.setSize( 310, 140 ); + setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); + add(new CanvasTest()); + this.setTitle( "绘制文本" ); + } + + public static void main(String[] args) { + DrawStringTest frame = new DrawStringTest(); + frame.setVisible( true ); + } +} -- GitLab