and12 -8 Light Poster

The assign was a game called FortuneCity
The prof wanted us to follow the MODEL - VIEW - CONTROLLER implemention.
The MODEL contains only functions that can be used in the game. It has NO GUI stuff in it.
The VIEW contains only contains the GUI interface.
The CONTROLLER allows Model and View to interact.

He gave us the model class which was called FortuneCity.java but he expected us to create the View and Controller part. So i did.

Inside his MODEL, the FortuneCity class

public class FortuneCity 
{ 

private FortuneCityView view; //that's the GUI view 

private Player [ ] players = new Player[3];

...
...
...etc.

public FortuneCity() //constructor 
{ 
view = new FortuneCityView(this); //passes the MODEL into the VIEW

....
....
....etc.

}

//methods in MODEL (NO GUI STUFF)
...
...
...etc.

public static void main(String[] args) 
{ 
FortuneCity game = new FortuneCity(); 
JFrame frame = game.view; 
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
frame.setSize(1200,700); 
frame.setVisible(true); 
} 
}

//FortuneView - I wrote this myself and includes CONTROLLER inside (ActionPerformed stuff)

public class FortuneCityView extends JFrame implements ActionListener, KeyListener { 
private FortuneCity game; 
JLabel heading;

....
....
....etc.

public FortuneCityView(FortuneCity w) { //I pass the MODEL object in it. 
game = w; // I refer to the MODEL and call it game

//methods in FortuneView
//I use MODEL methods by using game.[something] ex. game.startARound()
...
...
...etc.
}

The above works as an APPLICATION.

But I need to turn it into AN APPLET AND APPLICATION.

I tried the following

#1. I extends JApplet in the FortuneCity (MODEL class):

public class FortuneCity extends JApplet 
{ 
private FortuneCityView view; //that's the GUI view 

private Player [ ] players = new Player[3];

...
...
...etc.

#2. I change FortuneCity constructor into an init() class
Thus public FortuneCity()

becomes public void init()

#3. I change the main to get the applet and put into the frame:

public static void main(String [ ] args) 
{ 
JFrame frame - new JFrame("Fortune City"); 
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
frame.setSize(1200,700); 

FortuneCity applet = new FortuneCIty() //create applet 
applet.init(); //call init 
frame.setVisible(true); 
}

The result is that I get a blank frame when I compile and run it.

But I'm not sure if i am suppose to be adding the applet.view. But I tried frame.add(applet.view) and I get an run time error message on that if i do.

Please help me.

I also tried converting it to an APPLET ONLY by removing the main() but when i call the applet from an .html file, it says applet not initialized in the
browser.

I am new to this JAVA. I hope someone will be patient with me. The code works fine as an application until i try to change it to work for both an applet and application OR if i change it to be an APPLET only.