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 setting value as zero in Textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting value as zero in Textbox " Watch "setting value as zero in Textbox " New topic
Author

setting value as zero in Textbox

Gokulakannan Vasu
Greenhorn

Joined: Jan 11, 2011
Posts: 14
Hi...I have 4 text boxes,which should show value as '0' by default while display.I have two modes 'Insert' & 'Modify'.When i give insert mode,i can give values for that textboxes.when i select 'modify' i can edit the values.The thing is,i should get all my textbox value as '0' for insert mode and i should get values which i entered and stored for those text boxes when i select 'modify' mode;

1. 0 should be shown,when i select insert
2. Stored value should be shown when i selected modify

Code as follows:
// for insert mode
protected void insertThresholdDetail() {

getMajorPctField().setText("0");
getCriticalPctField().setText("0");
getMajorPctNERField().setText("0");
getCriticalPctNERField().setText("0");
getMajorPctALOCField().setText("0");
getCriticalPctALOCField().setText("0");
getMajorPctNREField().setText("0");
getCriticalPctNREField().setText("0");
}


protected void modifyThresholdDetail() {
getCriticalPctNERField().setText(""+detailedThreshold.getCriticalPctNER());
getMajorPctALOCField().setText(""+detailedThreshold.getMajorPctALOC());
getCriticalPctALOCField().setText(""+detailedThreshold.getCriticalPctALOC());
getMajorPctField().setText(""+detailedThreshold.getMajorPct());
getCriticalPctField().setText(""+detailedThreshold.getCriticalPct());
getMajorPctNREField().setText("0"+detailedThreshold.getMajorPctNRE());
getCriticalPctNREField().setText("0"+detailedThreshold.getCriticalPctNRE());
}


How should i do this...please help me...!!!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

So you should be having the Event Handlers for your Insert and Modify events? And if you have- then you can call these methods in the respective event handlers. If not, then you would have to create Event handlers and then go ahead. If you are using JButton- then look at ActionListener.

Also please wrap your code with code tags - UseCodeTags


Mohamed Sanaulla | My Blog
 
wood burning stoves
 
subject: setting value as zero in Textbox