mypanel.java~4~
来自「Jbuilder100个例子 都是经典例子 对大家学习Jbuilder非常有帮助」· JAVA~4~ 代码 · 共 58 行
JAVA~4~
58 行
package coordinate;import java.awt.*;import javax.swing.JPanel;import java.awt.geom.*;/** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */public class MyPanel extends JPanel { BorderLayout borderLayout1 = new BorderLayout(); private Ellipse2D.Double circle = new Ellipse2D.Double(10, 10, 350, 350); private GradientPaint gradient = new GradientPaint(0, 0, Color.red, 175, 175, Color.yellow,true); public MyPanel() { try { jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } void jbInit() throws Exception { this.setLayout(borderLayout1); } public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; g2d.setPaint(gradient); g2d.fill(circle); g2d.setColor(Color.blue); g2d.draw(circle); g2d.translate(180.0 , 180.0); for (int i=0; i<1; i++) { // Rotate the coordinate system around current // origin, which is at the center of the circle. g2d.rotate(16*Math.PI/16.0); g2d.setFont(new Font("TimesRoman",Font.PLAIN,100-i*2)); if (i%2 == 0) g2d.setPaint(Color.black); else g2d.setPaint(Color.white); g2d.drawString("Java", 0, 0); } } protected void clear(Graphics g) { super.paintComponent(g); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?