About this TutorialThis tutorial will illustrate how to create a simple networkable game using the gfw api. Sample GameThe sample game in this illustartion will be...
1: import javax.swing.JFrame;
2: import javax.swing.JMenu;
3: import javax.swing.JMenuBar;
4: import javax.swing.JMenuItem;
5: import javax.swing.JPopupMenu;
6:
7: import net.mlw.gfw.client.ClientContext;
8: import net.mlw.gfw.client.DefaultClient;
9: import net.mlw.gfw.ext.basic.action.NewGameActionListener;
10: import net.mlw.gfw.server.impl.DefaultServer;
11:
12: public class Sample extends DefaultClient
13: {
14: protected final JMenuBar menuBar = new JMenuBar();
15: protected final JMenu menuGame = menuBar.add(new JMenu("Game"));
16: protected final JMenuItem menuFileNewGame = menuGame.add(new JMenuItem("New Game"));
17:
18: public final void init(final ClientContext clientContext)
19: {
20: setJMenuBar(menuBar);
21: menuFileNewGame.addActionListener(
22: new NewGameActionListener(this, server, DefaultServer.class,
clientContext, clientEventHandler) );
24: }
25:
26: public static void main(String[] args)
27: {
28: JPopupMenu.setDefaultLightWeightPopupEnabled(false);
29: Sample sample = new Sample();
30: sample.initialize(new ClientContext());
31: sample.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
32: sample.setSize(340, 250);
33: sample.setVisible(true);
34: }
35: }
|