Results 1 to 2 of 2
- 08-02-2011, 01:18 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 33
- Rep Power
- 0
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)
Here's the secondJava 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; }
Java Code:public void setString() { gui1.setTextMainField("THIS IS PASSED FROM SECOND CLASS"); }
- 08-02-2011, 01:34 PM #2
Similar Threads
-
How can I append text in JTextArea from another class
By chikaman in forum AWT / SwingReplies: 13Last Post: 12-11-2009, 08:43 AM -
Pass String[] into method in different class
By Swankee in forum New To JavaReplies: 19Last Post: 09-28-2009, 05:30 PM -
[SOLVED] How to pass information from child class to parent class
By pellebye in forum New To JavaReplies: 7Last Post: 05-06-2009, 12:42 PM -
passing text from a class to a gui class
By rob in forum AWT / SwingReplies: 2Last Post: 02-13-2009, 11:04 PM -
unable to pass value from one class to another
By ddatta8 in forum New To JavaReplies: 14Last Post: 12-28-2008, 02:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks