Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Frame or applet

Started by Psionic-X May 12, 2003 at 11:09 AM 5 replies 500+ views
Original Post
Psionic-X
Psionic-X
I am trying to play around with threads and double buffering and i was wondering if it was possible to use a normal Frame derived frome the class Frame as a source to load images and how to go about that.. or would it just be easier to start out and try it on an applet??? ------------------------------ Exsiting in every essence of time I will find you! You will answer my Question! -Psionic-X- Existing from a greater plane
------------------------------Exsiting in every essence of time I will find you! You will answer my Question!-Psionic-X- Existing from a greater plane
garazdawi
garazdawi
You can use anything that inherits from Component to load images and stuff. I assume you are going to use a MediaTracker to keep an eye on the images if not do so :D

As for using an Applet..... it is better if you do it in the form that the Program will finally take...so if the game you are creating is an Applet game use an Applet...if not use an Application
garazdawi - 'I put the laughter back in slaughter'
Psionic-X
Psionic-X
ive never used MediaTracker.. where can i find info on it.?

------------------------------
Exsiting in every essence of time I will find you! You will answer my Question!

-Psionic-X- Existing from a greater plane
------------------------------Exsiting in every essence of time I will find you! You will answer my Question!-Psionic-X- Existing from a greater plane
CaptainJester
CaptainJester
http://java.sun.com/docs/books/tutorial/uiswing/painting/improvingImageAnim.html



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
darkWang
darkWang
i got this spiffy little book titled...

JAVA 2 GAME PROGRAMMING.

i think all and all it is a good book, i am not a begginer programmer and have background in c++ and took one java class.

This book explaines how to implement lots of game technique. just a suggestion.
Psionic-X
Psionic-X
so i understand how you would load an image but i dont know how tp get it to work on a normal framw so ive been searching around and found that applet is derived from panel. but now im not sure exactly how panels work and how youd get that to work with a frame or show on screen.

-----------------------------------------------------------------
Exsiting in every essence of time I will find you! You will answer my Question!

-Psionic-X- Existing from a greater plane

[edited by - Psionic-X on May 14, 2003 10:28:22 PM]
------------------------------Exsiting in every essence of time I will find you! You will answer my Question!-Psionic-X- Existing from a greater plane
Aldacron
Aldacron
Here''s a few points that might help you:

When loading an image from disk rather than from a URL (as an applet does), use Toolkit.getDefaultToolkit.getImage( imageName ). It doesn''t matter if your class is a Frame, a Panel, or just a normal Object subclass.

To add any Component (a Panel, Canvas, or whatever) to a Container such as an Applet or a Frame, use the Container''s add method.

To make a program which can be used as both an Applet or an Application, make a class that extends Applet. Override the functions you need (init, start, stop). Then, add a main method. In the main method, you create a Frame, add the Applet to the Frame, call init, then start. You''ll also have to provide a way to call stop if you need it. When you put the Applet on a web page, main will never be called and the Applet''s methods will be called autmatically. When you run the Applet with the jre on your computer, the main method gets called and your Applet effectively becomes an application. The thing to watch out with this set up is that you how you load your resources.

You say you aren''t sure how Panels work. A Panel is a Container which is often used to group Components inside another Container. It generally is not used itself to display images. What normally is done, create the components you need to display (buttons, listboxes, etc...) and add them to the Panel. Then, add the Panel to the app''s root container. Int an applet, the Applet is the root container. In an application, the Frame is the root container. For drawing images, you should use a Canvas, or a subclass of Canvas, and add that to another container, such as your applet.

If you haven''t done so already,read either the Swing Tutorial or the old AWT Tutorial, which is no longer available online but can be downloaded here.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.