Re: Custom Method as jTextArea Text?

Wade Chandler <[email protected]> Fri, 30 May 2008 11:49:13 -0700 (PDT)
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>
--- On Fri, 5/30/08, Barry_C <[email protected]> wrote:
> From: Barry_C <[email protected]>
> Subject: [nbui] Custom Method as jTextArea Text?
> To: [email protected]
> Date: Friday, May 30, 2008, 2:23 PM
> I want my jTextArea text to be the value returned from a
> class method. 
> 
> I have the following class:
> 
> /***********************************/
> public class Appointment {
> 
> 	//Fields
>         private String note;
>         
> 	//Constructors
> 	public Appointment() {
>             note = "This is what you get.";
> }
> 	//Methods
>         public String getNote() {
> 		return note;
> 	}
> 	public void setNote(String anyName) {
> 		this.note = anyName;
> 	}        
> /****************************************/
> 
> Then my jTextarea code looks something like this:
> 
> /****************************************/
> import com.miginfocom.beandemo.Appointment;
> 
> public class ApptDetails extends javax.swing.JDialog {
>     
>     /** Creates new form ApptDetails */
>     public ApptDetails(java.awt.Frame parent, boolean
> modal) {
>         super(parent, modal);
>         initComponents();
>     }
>  private void initComponents() {
> jTextArea1 = new javax.swing.JTextArea();
> 
>         jTextArea1.setColumns(20);
>         jTextArea1.setRows(5);
>         jTextArea1.setText(getNote());
>         jScrollPane1.setViewportView(jTextArea1);
> }
> /*******************************************/
> 
> It yacks on the call to getNote(). What is the proper
> syntax for this?

Please review the description at:
http://www.nabble.com/Netbeans---UI-f2608.html

and note this is not a support forum. Please use [email protected] for such things, or in this particular case, you can get better support at:
http://forums.java.sun.com

as this is just a standard Java question of how to use instances and classes.

Notice you are in another class where the call to getNote takes place. You should have an instance of Appointment some where to call getNote against. Thus we'll call it app:
Appointment app = new Appointment();
//some code to setup app
//later you call
jTextArea1.setText(app.getNote());

Wade

==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org