File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes unable to clear text box in Multi Screen JFrame GUI Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "unable to clear text box in Multi Screen JFrame GUI Application" Watch "unable to clear text box in Multi Screen JFrame GUI Application" New topic
Author

unable to clear text box in Multi Screen JFrame GUI Application

harsh rocking
Greenhorn

Joined: Apr 26, 2010
Posts: 12
i am working with a Swing GUI project where I want to accept user input in a
text field
I have used singleton pattern which will create only one instance of object
due to this when i move from one scree to another the input of textfield
doesnt updated I have used setText method to clear the JTextField but it wont
works
I have attached the code here which consists of two files
Program one -- 1st screen



program 2 - 2nd screen


In this application the status of TextField input remain same means it shows
the earlier input in the textfield wnen I come to earlier or next screen.
what is the solution to clear the TextField input while moving from 1st
scrren to 2nd screen.
Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

Welcome to JavaRanch,

Please UseCodeTags to make your code easier to read.


Olly
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

You are adding an action listener to the button inside one action listener.
So who calls the first action listener? If the action listener is never called, do you think the setText("") would ever be executed?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
is the only thing the current crop of greenhorns know how to do well is to cross-post?
is it part of the training?

http://forums.sun.com/thread.jspa?threadID=5437051&tstart=0

recently, just about every first-time poster posts all over the place.

very frustrating, getting close to being a total waste of time trying to help these people

[edit]

but wait, there's more

http://www.java-forums.org/awt-swing/28193-unable-clear-text-field-multi-screen-jframe-gui-application.html
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Thanks Michael.

Harshal,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
harsh rocking
Greenhorn

Joined: Apr 26, 2010
Posts: 12
Hello Michael I Think These site managed separately by different groups.
I am really sorry for cross posting.
Please help in the above situation.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Please help in the above situation.

posting everywhere indicates my time is unimportant to you,
therefore you getting a solution is equally unimportant to me.
harsh rocking
Greenhorn

Joined: Apr 26, 2010
Posts: 12
Michael Dunn wrote:> Please help in the above situation.

posting everywhere indicates my time is unimportant to you,
therefore you getting a solution is equally unimportant to me.


I am sorry I am new to all these forums I don't know about the multiple posting
I will follow the code of conducts here on Michael.
Please share your knowledge with me. I am working on this code on last few
days but I am unable to solve this. Please help me your time is very important for me.
I am sorry..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Did you read my previous reply?
harsh rocking
Greenhorn

Joined: Apr 26, 2010
Posts: 12
Maneesh Godbole wrote:Did you read my previous reply?

Please help me I am novice to the Swing
the application might needs to use observer design pattern I think
I am also tried it but it wont work. I had worj on above code lot.
Please help me
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Since you are not willing to answer even simple questions like "did you read my previous reply" I do not see how else to further help you.
harsh rocking
Greenhorn

Joined: Apr 26, 2010
Posts: 12
Maneesh Godbole wrote:Since you are not willing to answer even simple questions like "did you read my previous reply" I do not see how else to further help you.


Yes I have read your earlier post and go through the link you have posted their.

As you say setText("") is executing properly but it is unable to clear the TextField in the GUI
The above application is working properly and is response to the button action very well
the problem is that I have used singleton design pattern which create only one object
of the Class if I doesn't use singleton then it works properly but that is bad coding as it create new object
each time. So in singleton approach their is single object which is unable to update the state next time
when i call setText("") function to clear the textField
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to clear text box in Multi Screen JFrame GUI Application