I've started a new project, and decided to use Swings JApplet instead of Applet because I like all the nice things you can do.
However, I find Swing a bit more complex than I expected, since most graphical components are usually modified indirectly by modifying some sort of Model, I have variables declared all over the place, and I really don't know where the right place to declare the components is.
So here's the question: the Java tutorial shows examples where applet variables are declared in the class itself and in the init() method e.g.
BEGIN CODE SNIPPET...
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class MultiListener extends JApplet
implements ActionListener {
//Glenn's comment: class variables...
JTextArea topTextArea;
JTextArea bottomTextArea;
JButton button1, button2;
final static String newline = "\n";
public void init() {
//Glenn's Comment: more variables??
JLabel l = null;
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JPanel contentPane = new JPanel();
//Glenn's comment:
//another variable the same name as the class variable?
button1 = new JButton("Blah blah blah");
END CODE SNIPPET
Here's a similar problem, I have a table (visual interface object) and I want to populate it with data from my database (business object), I want to keep the buisness stuff away from the interface stuff, so where do I create my buisness object, if so, how do I pass it to the interface object?
Hope somebody can help