Archived

This topic is now archived and is closed to further replies.

Arch@on

[java] What can you do with Java2D?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites