当我添加该功能g2d.rotate(some Number)
时,屏幕根本没有显示任何形状,没有此功能一切正常。
问题是什么?
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(color);
Polygon polygon = new Polygon(xCordinate,yCordinate,4);
// g2d.rotate(Math.toRadians(45));
g2d.draw(polygon);
g2d.fill(polygon);
}
主要是:
public class Main extends JPanel {
Camera c=new Camera(100, 50, (Math.PI)*2, 0, 150,200,Math.PI,Color.MAGENTA);
//Camera c1=new Camera(100, 50, (Math.PI)*2, 0, 150,200,0,Color.black);
public static void main(String[] a) {
JFrame f = new JFrame();
f.setSize(400, 400);
f.add(new Main());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public void paint(Graphics g) {
//c1.paintComponent(g);
c.paintComponent(g);
}
}