Example of Graphics2D class:
Code:
import java.awt.Graphics2D;
import javax.swing.JPanel;
public class GPMainClass extends JPanel {
public void paint(Graphics gV) {
g.fillRect(0, 0, 30, 30);
Graphics2D gp2 = (Graphics2D) g;
gp2.translate(50, 50);
gp2.rotate(30.0 * Math.PI / 180.0);
gp2.scale(2.0, 2.0);
gV.setColor(Color.red);
gV.fillRect(0, 0, 30, 30);
}
public static void main(String[] arcgs) {
JFrame ZLP = new JFrame();
ZLP.getContentPane().add(new MainClass());
ZLP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ZLP.setSize(200, 200);
ZLP.setVisible(true);
}
}
Bookmarks