start gamming problem(if post wrong i am sorry)

now i starting to make a game .now i have my menu page,but i don't know the structure of java file.what file should i have in the structure ?

(eg.menu.java,main.java,?,?)if there must a main.java, what is main.java use for?and what is the main structure code?

i ask this question because i saw applet game have start(),run() and some other method.But now i am using Jframe for the game.

i don't know if i use Jframe to make a game what should i think and start first.

thanks for coming to see my post

[534 byte] By [nickgoldgodla] at [2007-11-27 3:54:46]
# 1

what file should i have in the structure? (eg.menu.java,main.java,?,?)

It is 100% up to you. You can put things together any way you want. One of the main design guidelines is that it makes sense to you and is easy to read.

if there must a main.java, what is main.java use for?

You will need a main method for an entry point into your application. The vurtual machine (jvm) looks for this method signature

public static void main(String[] args) {

as the place to start. Where you put it is up to you.

and what is the main structure code?

Depends on what you are doing and how you want to do it.

i ask this question because i saw applet game have start(),run() and some other method.But now i am using Jframe for the game.

i don't know if i use Jframe to make a game what should i think and start first.

Applet methods are used by the applets AppletContext. You use the init method to put your applet together, much like you use a constructor in an application. The start and stop methods are used (by overriding them in the applet) to start and stop animations when the applet page is visible/restored and not-visible/minimized.

Foe some ideas about what is possible it is good to look at examples. You can find many examples by searching or browsing these forums. The java tutorial is another good place to learn about building applications. It has discussion and many examples.

Some suggestions:

For complex applications you can encapsulate areas of your code according to function (what they do) by building multiple classes and arrange for the classes to talk with one another.

public class Class1 {

member variables as needed

void doSomethng() {

methods as needed

public void static void main(String[] args) {

make up a JFrame, configure it and add components

build your gui and add (local) listeners

}

}

class GraphicsClass extends JPanel {

memeber variables as needed

protected void paintComponent(Graphics g) {

custom drawing happens here

}

}

class EventClass {

member variables as needed

keep your event code here for

for things like Mouse operations or

animations with Swing timers or threads.

}

Or you can put your main method inside a class.

class GraphicsComponent extends JPanel {

protected void paintComponent(...

public static void main(String[] args) {

make up gui, add component and show it

}

crwooda at 2007-7-12 8:58:54 > top of Java-index,Security,Cryptography...
# 2
thanks a lot you make me know more about java thanks^^
nickgoldgodla at 2007-7-12 8:58:54 > top of Java-index,Security,Cryptography...