This commit is contained in:
2022-05-01 23:24:00 +08:00
parent 0b354c7561
commit 053113577f
16 changed files with 493 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public class MyPanel extends JPanel {
@Override
protected void paintComponent(Graphics g) {
// clean the panel
super.paintComponent(g);
// draw
g.setColor(Color.RED);
g.drawRect(30, 30, 60, 60);
g.drawRect(15, 40, 60, 60);
g.drawLine(30, 30, 15, 40);
g.drawLine(90, 30, 75, 40);
g.drawLine(90, 90, 75, 100);
g.drawLine(30, 90, 15, 100);
// use g to draw a Cylinder
g.setColor(Color.BLUE);
g.drawOval(120, 20, 60, 20);
g.drawLine(120, 30, 120, 90);
g.drawLine(180, 30, 180, 90);
g.drawOval(120, 80, 60, 20);
}
}