Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie(ish) - awt to swing ? (and some more general java questions) 1

Status
Not open for further replies.

joezapp

Programmer
Feb 26, 2001
63
GB
Hello all.

I've written an interactive graphing applet, using awt / canvas. This has involved me pretty much learning java as I go (my 'forte', such as it is, is pl/sql, javascript, dhtml and perl so I'm not a total newbie to programming). However - its not the fastest thing on the block and I'd like to improve it.

To that end I've a load of general java questions:

Would it be better / advisable to rewrite using swing ? The components look easier to use but is it more efficient / speedy ? (I know this is obviously subject to the standard of my code). Not sure if its that relevant but I have control over the versions of jre my end users will be running so backwards compatibility isn't that much of a problem.

I often have to have multiple graph applets on one page and it looks like multiple jres are opening and running (which takes a while to do). Would this be the case ? Is there a way to make this less resource intensive ?

Is there a way to open a jre in the background when a user logs onto the site or to preload any resources an applet might need ? This would mean that graph browsing would become much faster to initiate.

I think thats pretty much it.

thanks in advance to any help you might me able to send my way :)


cheers

Joe.
 
There's loads of discussion over the speed of Swing compared to awt. My general thought is that Swing will be slightly slower to run, but as is it is easier to use, you are more likely to write good oo code and it may run faster.

I don't think that you can share a jre between applets, but I look forward to someone proving me wrong :)

If you're looking for faster code you should look at: how you hold and move around lumps of data (i.e. hold the data once and don't create copies), how object-oriented your code is, and whether you can use threading to separate processing tasks from drawing tasks. Jeremy Nicholson, Director of a UK-based Java and Data Warehousing consultancy
 
Hi joezapp:

It is better to code with Swing, for example, you can show your interfaces with the native system look & feel, which you are not able to do with awt. The main point here is not performance but portability. There is no main difference in the performance of an awt vs swing application, but, the internet browsers work with previous versions of the JVM (depends on the browser version) and it could be necessary to install a plugin to run your Swing applets. But, as you say, you can control the JVM version of your clients, so I don't see a problem.

About the different "jre" loading your application, I'm not sure, but I think that a web browser have a single instance of the JVM and over it runs every applet the browser loads. I don't know if I didn't understand, but, there should be a single instance of the JVM for your application and any other.

To improve the applet performance you can compress your files in a single jar (so, the browser sends just one GET instruction to the server, instead of one GET for each class), and as posted early, look for cache mechanisms. Java web start works fine, if you have a standalone application.

Hope it helps.
 
thanks for all suggestions.

idarke - have a star for pointing me in a new direction. Not sure if it'll fit the bill but its worth a look and I wouldn't have found it otherwise...

I'll go through my code again and try and look for anywhere I can improve array handling etc. I've already got all my classes and images in a single .jar so that bits licked.

Thanks again. All suggestions gratefully recieved :)

Joe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top