📄 myframe.java
字号:
import java.awt.*;
import javax.swing.*;
public class MyFrame extends JFrame{
//JButton btn = new JButton("red");
JPanel p = null;
public MyFrame(){
this.setSize(600,600);
//this.setTitle("title");
p=(JPanel)this.getContentPane();
//p.setLayout(new FlowLayout());
//p.add(btn);
p.add(new MyDraw());
//this.setBounds(200,200,400,300);
this.setVisible(true);
}
public static void main(String [] args)
{
new MyFrame();
}
}
class MyDraw extends JPanel{
public MyDraw(){
this.setSize(500,500);
System.out.println("aaaaaaaaaaaaaaa");
}
public void paintComponent(Graphics g){
//g.setColor(Color.red);
//g.drawOval(50,50,50,50);
g.setColor(Color.black);
g.fillPolygon(new int[]{0,300,600,600,0},new int[]{300,0,300,600,600},5);
g.setColor(Color.pink);
g.fillArc(200,200,200,200,20,360);
g.fillArc(250,400,100,100,20,360);
g.setColor(Color.red);
g.fillArc(250,300,10,20,20,360);
g.fillArc(330,300,10,20,20,360);
g.fillRect(290,330,10,10);
//g.fillArc(270,430,20,20,20,360);
//g.fillArc(310,430,20,20,20,360);
g.fillRect(200,400,200,10);
g.fillRect(275,500,10,100);
g.fillRect(315,500,10,100);
g.setColor(Color.blue);
g.drawString("ddddd",20,20);
Graphics2D g2d = (Graphics2D)g;
g2d.set
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -