• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Swinging around

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
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");
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
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic