lab10
This commit is contained in:
27
lab/lab10/Question7/MyPanel.java
Normal file
27
lab/lab10/Question7/MyPanel.java
Normal 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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user