In an introductory book on Java, a simple method for doing Java 2D graphics is described in these steps: 1. Extend JPanel 2. override void paintComponent(Graphics g) 3. cast (Graphics g) to (Graphics2D) 4. use the J2D API from here.
Is this the only way, or was this just a simple introduction? The reason I ask is that there are some faults with it. The two main problems I have are: 1. The drawing flickers every time i move the JFrame containing it. 2. It won't seem to compile with gij under linux! i get the error
java.lang.ClassCastException: gnu.java.awt.peer.gtk.GdkGraphics cannot be cast to java.awt.Graphics2D
Gcj is wrong here in not using Graphics2D objects. That's par for the course, though; Gcj doesn't conform to every little wrinkle of Sun's Java implementation. You can use (and frankly, should be using) Sun's JDK on Linux, and then of course this problem will go away.
The flickering shouldn't happen; are you calling super.paintComponent() in your implementation?