Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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
    Bookmark Topic Watch Topic
  • New Topic