Results 1 to 14 of 14
Thread: code for cleaning variables?
- 08-21-2008, 05:38 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
-
Hm, I'm not sure I fully understand here. Do you mean to clear the contents of a JTextField? If so, there's the setText("") method that would work nicely. If not, then you'll have to clarify this a bit more. HTH.
- 08-21-2008, 08:53 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
yes exactly
that method is what i mean
string s
get.txtValueA
Value A=Integer.parseInt sort of
the code to clear the text fields
thanks if you have the solution
-
um... that is the solution. You call setText("") on your JTextField when you want to clear it.
- 08-21-2008, 09:37 PM #5
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
Just relieved thanks
ok so how would you assign this to a button function ? with the example above?
- 08-21-2008, 09:50 PM #6
-
Since you are just now learning Swing, I advise against using NetBeans or similar to generate Swing code. Better at this stage would be for you to create all your own Swing code, and later after you are more familiar with what Swing does, then fine go ahead and use NetBeans.
But as to your question, you will need to add an ActionListener to the button that has the code that you want processed when the button is pressed. To learn how to do this (and to learn more about Swing in general) please check out the Sun Swing tutorials:
The Sun Swing Tutorials
The ActionListeners tutorial
- 08-21-2008, 10:00 PM #8
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
meaning i type the code after assigning the code generation of the text variables
i.e txtNumber 1
txtNumber2 when i right click the button (erase) for example
- 08-21-2008, 10:04 PM #9
Clearly my friend @Fubarable and I have a different viewpoint.
Clearly you can do what he suggests. But I find a lot of Swing to be ugly and repetitive, so I much prefer to have the IDE solve the boring administrative tasks and focus on the domain stuff.
YMMV, of course
- 08-21-2008, 10:05 PM #10
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
thanks ill check it out now
- 08-21-2008, 10:08 PM #11
Member
- Join Date
- Aug 2008
- Posts
- 17
- Rep Power
- 0
oh That site ive tried to understand it through but still getting errors thats why im posting questions here through your expertise off course to understand better
I use NetBeans 5.5 and Forte Java 4Last edited by Ak-Emm; 08-21-2008 at 10:11 PM.
-
I don't disagree here at all, and I think it is fine to use NetBeans to get away from some of the grunt work associated with Swing coding.
But having said that, I know that I have seen (and I'm sure that you have too) many posts in this and other Swing fora filled with problems from folks who use NetBeans to generate their Swing code but who run into brick walls because they just don't understand what that Swing code is doing. All I'm saying is to learn Swing for say a month or four, and then, fine, let NetBeans do the dirty work.
- 08-22-2008, 02:35 AM #13
I've found that knowing what goes on under the covers to be very useful. Keeps it from being FM.
- 08-22-2008, 02:40 AM #14
Similar Threads
-
Collecton of Variables
By c26354 in forum New To JavaReplies: 12Last Post: 06-30-2008, 03:09 PM -
Using Static Variables
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:08 PM -
Initialize variables before use
By Java Tip in forum Java TipReplies: 0Last Post: 12-22-2007, 11:22 AM -
Variables
By mew in forum New To JavaReplies: 3Last Post: 12-11-2007, 12:44 PM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks