Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java Notes

Where to declare components

Components are typically declared in one of several places:

Field variables

Some components should be declared as field variables (instance variables, member variables). This is the appropriate place to declare components which must be referenced after the interface is constructed. Typically these are text fields or text areas, check boxes, etc. Those components whose values must be gotten or set.

Local variables

Local variables should be used for components which are never referenced after the interface is constructed. Typically these are panels for holding components, buttons (whose interaction is thru their listeners), ... Local variables disappear when the method they are in returns, but the component will continue to exist if it has been added to the interface.

Anonymous

Anonymous creation is typical with labels, which can be created and added in one step and never assigned to a variable. Of course, if the appearance (font, alignment, ...) must be changed, then they should be put in a local variable. Some programs use labels for output (not a good idea), and in this case they should be field variables. Example
content.add(new JLabel("Look at this"));
Ask programming questions?

 

 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.

[an error occurred while processing this directive]