Results 1 to 2 of 2
  1. #1
    jeata is offline Member
    Join Date
    Oct 2010
    Posts
    33
    Rep Power
    0

    Default Pass text to jTextArea class from another class(different layers)

    I have two classes. One is a GUI with a textArea, a jButton and a method to set text in the text field. The other contains just one simple void method called setString which needs to pass a string to the first class. I think everything is as it should be, but somehow it gives me a bunch of exceptions

    Here's the first class(The GUI)
    Java Code:
    private JTextArea getJTextArea() {
    		if (jTextArea == null) {
    			jTextArea = new JTextArea();
    			jTextArea.setBounds(new Rectangle(11, 6, 417, 160));
    		}
    		return jTextArea;
    	}
    
    	/**
    	 * This method initializes getParts	
    	 * 	
    	 * @return javax.swing.JButton	
    	 */
    	private JButton getGetParts() {
    		if (getParts == null) {
    			getParts = new JButton();
    			getParts.setBounds(new Rectangle(232, 174, 193, 25));
    			getParts.setText("SET TEXT");
    			getParts.addActionListener(new java.awt.event.ActionListener() {
    				public void actionPerformed(java.awt.event.ActionEvent e) {
    					gc1.setString();
    					
    				}
    			});
    		}
    		return getParts;
    	}
    Here's the second
    Java Code:
      public void setString()
        {
        	 gui1.setTextMainField("THIS IS PASSED FROM SECOND CLASS");
        }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,884
    Rep Power
    25

    Default

    it gives me a bunch of exceptions
    Please copy and paste here the full text of the error messages.

Similar Threads

  1. Replies: 13
    Last Post: 12-11-2009, 09:43 AM
  2. Pass String[] into method in different class
    By Swankee in forum New To Java
    Replies: 19
    Last Post: 09-28-2009, 06:30 PM
  3. Replies: 7
    Last Post: 05-06-2009, 01:42 PM
  4. passing text from a class to a gui class
    By rob in forum AWT / Swing
    Replies: 2
    Last Post: 02-14-2009, 12:04 AM
  5. unable to pass value from one class to another
    By ddatta8 in forum New To Java
    Replies: 14
    Last Post: 12-28-2008, 03:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •