File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access TextField from another class

 
Primoz Karnekaj
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have two classes - main and GUI.
In main i start the GUI window like this:


On this window I have a textField which I want to update from my main class. However, I don't know how to access it. I tried

but it doesn't exist. Please help me, I got rusty in Java!
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post some code. Is JTextField the variable name of the textbox? Is it declared as an instance variable of the GUI class? Please refrain from using the class name as the variable name...
 
Primoz Karnekaj
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey John,
I managed to solve this problem. I had to set the modifier property of JTextField (yes, a textfield) to public and remove the tick from "Use local variable" - Both under Code tabs in Netbeans.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primoz Karnekaj wrote:. . . I had to set the modifier property of JTextField (yes, a textfield) to public and remove the tick from "Use local variable" . . .
Both of which look like mistakes to me.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic