Can anyone tell me what is the advantages of using Canvas to paint(shape eg. rectangle, oval, line) compare to using Applet(appln not using web browser).
Thank You Hydra
Keenan Staffieri
Greenhorn
Joined: Jul 22, 2006
Posts: 23
posted
0
you use canvas to paint for applications. you use applet for web browser. But you have to use applet if you want people to use your game on your website or someone else's immeditaly. you must use appletview to see applets offline. but canvas will paint just like applet does but possibly faster if you use openGL on canvas.
Hydra Iris
Greenhorn
Joined: Jun 21, 2006
Posts: 13
posted
0
Mm......Still need help
Let me rephrase my questions: My concern are drawing on an applet panel itself and drawing on Canvas.
My appln don't need to run on a web-browser, nor a game program. Is just a simple program full of shapes eg. oval, rects, lines, circles, etc., overlapping each other To draw these I can choose to draw directly on the applet panel or by extending Canvas class.
So, what I wants to know is which is the best method to use - using Applet or extends Canvas. And why too.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35253
7
posted
0
If it isn't running in a browser, then you should not use an applet. It doesn't work as you would expect outside of a browser/appletviewer environment. So the Canvas is really the only way to go.
But is not wrongly to paint on the applet panel right?
I came across a graph project which plot on an applet. This project (not meant for web browser) retrieve xy coordinates from the mdb file and draw on the applet's panel. It worked fine.
No canvas class was used at all. The main problem is - loading slow. So, I was wondering, will it be better if the plotting was done by extending canvas. Will the loading performance improved?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35253
7
posted
0
If this isn't an applet, then, yes, it is wrong to use an Applet. But Applet extends Panel, and since the extra functionality isn't used, you could just use a Panel.
Offhand I'm not sure why using Canvas vs. using Panel (or Applet) should make a big performance difference. Have you done some comparison timings with your application?
Hydra Iris
Greenhorn
Joined: Jun 21, 2006
Posts: 13
posted
0
Nope, never compare the 2 method.
I just want to confirm the performance of loading the graph is not due to the painting in applet or canvas.
My take on it is this - use a Canvas instead of drawing on the Applet itself. Why? Separation of concerns - have the applet simply deal with providing the "run in a webpage" capability, and how to get resources. Have the canvas deal with what canvas is good for - painting.
This way, it's easier to test each part separately, and if you ever need to "re-target" your application to run stand-alone, rather than as an applet, you've already separated the painting from the applet code - so it's much easier.
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Hydra Iris
Greenhorn
Joined: Jun 21, 2006
Posts: 13
posted
0
Noted.....Thanks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.