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 Getting input in textbox. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Getting input in textbox." Watch "Getting input in textbox." New topic
Author

Getting input in textbox.

Ranjeet Deshmukh
Greenhorn

Joined: Jan 18, 2013
Posts: 24

Hi all,

I'm trying to build calculator desktop application in netbeans. Problem is I'm not able to get many inputs in the text box (e.g- 123+456) by clicking on buttons(0,1---9, +, - ,*, / etc). Every time when I click on one(1) it get displayed but when I click two(2), one disappears. What shall I do?


~R@njeet.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
What is a "textbox"? I'm not aware of any Swing components by that name.
Ranjeet Deshmukh
Greenhorn

Joined: Jan 18, 2013
Posts: 24

sorry Rob,

I wanted to say Text field that shows the inputs and result of computation for calculator.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18110
    
    8

Again, what class is this "Text" field? Don't make us guess whether it's a JTextPane or a TextField or something else. Just tell us.
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

I will suppose that you have used JTextField...

In the actionPerformed() method I think you have writen:

You will see that this code only replace the text in the JTextField..
But you have to type 2 at the end of the text.

Therefore,
1. You have to get the text in the JTextField.
2. Then add 2 at the end of that text
3. Replace the text in JTextField with that text..

So, new code will be,


(I also have to say that, Don't make us to guess what is in your mind.. Use Class names correctly...)


Ramesh-X
Ranjeet Deshmukh
Greenhorn

Joined: Jan 18, 2013
Posts: 24

Sorry Ramesh and Paul for not to be specific.

Thanks Ramesh That was helpful, it solved my problem. If there will be any I will post again & of course I will be specific next time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting input in textbox.
 
Similar Threads
Exporting .jars from Eclipse
layered Pane issues
Open multiple Terminals in one frame
JFrame one instance
b1.addActionListener( this);