Recently there has been no time to write a blog, things more, quiet heart, things go with its natural good, and some things I do not understand why it will become so, you think you pay the most precious, but perhaps others do not like. Forget it, do not think much, let it be natural.
Java does not keep up with C + + in graphic drawing, but I think Java has some advantages in graphics, but for large desktop games, it is impossible to estimate even smoothness.
Here's the code for the most recent write:
Package Draw;import java.awt.*;import javax.swing.*;import java.awt.geom.*;p ublic class drawtest{public static void Main (string[] args) {Eventqueue.invokelater (new Runnable () {public void run () {JFrame frame=new drawframe (); Frame.settitle ("Draw"); Frame.setdefaultcloseoperation (jframe.exit_on_close); frame.setvisible (True);}});}} Class Drawframe extends Jframe{public Drawframe () {Add (New Drawcomponent ());p ack ();}} Class Drawcomponent extends jcomponent{private static final int default_width=400;private static final int default_height =400;public void Paintcomponent (Graphics g) {graphics2d g2= (graphics2d) g;double leftx=100;double topy=100;double width =200;double height=150; Rectangle2D rect=new rectangle2d.double (leftx,topy,width,height); G2.draw (rect); Ellipse2d ellipse=new ellipse2d.double (); Ellipse.setframe (rect); G2.draw (ellipse); G2.draw (New Line2d.double (LeftX, topy,width,height));d ouble Centerx=rect.getcenterx ();d ouble centery=rect.getcentery ();d ouble radius=150; Ellipse2d circle=new Ellipse2d.dOuble (Centerx,centery,centerx+radius,centery+radius); Circle.setframefromcenter (CenterX,centerY,centerX+radius, Centery+radius); G2.draw (circle);} Public Dimension getPreferredSize () {return new Dimension (default_width,default_height);}
This is, I was thinking about using Java to do the GUI, and then to invoke my previous project to write some of the DLL files, so the teacher let me do the interface is very easy, the mentor let me use OpenGL interface, I feel that this is not to develop a micro swing or WPF ...
Java Learning Java 2D Graphics drawing