[java] What can you do with Java2D?

Started by
4 comments, last by Arch@on 23 years, 11 months ago
I haven''t seen many things that would encourage me to use it. Do you have any demos or anything good looking done with it? All I have seen can be done with AWT with little bit better experience. Also, my second question is, when making custom graphical buttons should I extend it from AWT''s button and then call custombutton cb; -- init(); -- cb=new custombutton(mypicture, width, height, and so on); or create new one from Canvas and then code all needed stuff for it? Time comes, time goes and I only am.
Advertisement
When you installed your JDK there should have been a directory ''demo/jdc/j2d'' created as well. In that directory there is a file named ''Java2Demo.jar''. It pretty well hightlights J2D features. I think you will see that J2D offers several performance and feature advantages.

Of course, even on my relatively fast system performance wasn''t great. I don''t know if that''s just how the demo was written (it displays several features on each page) or if the performance of Java 2D was just being maxed out.
try looking at the javadocs and see what java.awt.button extends (or implements) ... it''s something like abstractButton class. If you just want a picture for a button you might want to look at imageIcon class, that''s what they use in the tool bars, so it might work.
Well for creating graphical buttons I just used:
public class MapEdButtons extends Canvas
{
Image mapEdButton;

public void update(Graphics g)
{
paint(g);
}

public void paint(Graphics g)
{
g.drawImage(mapEdButton, 0, 0, this);
}

public void setImage(Image img)
{
mapEdButton = img;
}
}

and in the main class just called setImage and then the paint for this class. It worked for me.

Smoo
quote:Original post by Smoo

Well for creating graphical buttons I just used:
public class MapEdButtons extends Canvas
{
Image mapEdButton;

public void update(Graphics g)
{
paint(g);
}

public void paint(Graphics g)
{
g.drawImage(mapEdButton, 0, 0, this);
}

public void setImage(Image img)
{
mapEdButton = img;
}
}

and in the main class just called setImage and then the paint for this class. It worked for me.

Smoo


Yeah, I know, but is it faster than extending from normal button? It has serveral good things like ready made animation. I don''t want use swing, because A) It''s slow B) It doesn''t support gif''s natural transparency so I have to use slow swing features to do that because AWT way did not work.

Does anyone know where to get BMP file format extension/usage class?



Time comes, time goes and I only am.
If you want to see some neat things you can do with java, go to this site. Check out the raycast engine especially.

http://www.2nu.com/Wayne/index.html

This topic is closed to new replies.

Advertisement