Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Swinging around

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic