📄 texture1.java
字号:
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
public class Texture1 extends Frame{
Paint tPaint1, tPaint2, tPaint3, tPaint4;
public Texture1(String title){
super(title);
BufferedImage buf= new BufferedImage(10,10,BufferedImage.TYPE_INT_RGB);
Graphics2D g2buf=(Graphics2D)buf.getGraphics();
g2buf.setPaint(new Color(100,100,255));
g2buf.fill(new Ellipse2D.Float(0,0,10,10));
tPaint1=new TexturePaint(buf, new Rectangle.Float(10,50,10,10));
tPaint2=new TexturePaint(buf, new Rectangle.Float(100,50,15,15));
tPaint3=new TexturePaint(buf, new Rectangle.Float(190,50,20,20));
tPaint4=new TexturePaint(buf, new Rectangle.Float(280,50,25,25));
}
public void paint(Graphics g){
Graphics2D g2=(Graphics2D)g;
g2.setPaint(tPaint1);
g2.fill(new Rectangle2D.Double(10,50,80,200));
g2.setPaint(tPaint2);
g2.fill(new Rectangle2D.Double(100,50,80,200));
g2.setPaint(tPaint3);
g2.fill(new Rectangle2D.Double(190,50,80,200));
g2.setPaint(tPaint4);
g2.fill(new Rectangle2D.Double(280,50,80,200));
}
public static void main(String[] args){
Frame f=new Texture1("鸥老 瓤苞");
f.setSize(400,300);
f.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -