Results 1 to 4 of 4
Thread: netbeans/java help
- 11-02-2010, 04:38 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
netbeans/java help
im using netbeans for my java course, i have made a basic pizza program, but want to make it better visually and funtionally(if thats a word) i was wondering if there was a way to enable a text area only if a certain check box has been selected -
i want to make it so.... when a pizza delivery check box is selected, the address text field becomes enabled to input data
would it be better to make it into radio buttons?
any help would be great
i was thinking to get my teacher to view the program and order a pizza, then actually call a pizza place to get one delivered - thats programming lol :D
heres my code.....
Java Code:private void btnexitActionPerformed(java.awt.event.Ac… evt) { System.exit(0); } private void btnsubmitActionPerformed(java.awt.event.… evt) { String strname = ""; String straddress = ""; String strpizzatype = ""; double cost = 0.0; double amount = 0.0; double delivery = 4.00; String strquantity = " "; double quantity = 0.0; double garlic = 1; strname = txtname.getText(); straddress = addressfield.getText(); strquantity = quanfield.getText(); quantity = Double.parseDouble(strquantity); if (rdolarge.isSelected()) { strpizzatype = "large"; cost = 10.00; } if (rdomedium.isSelected()) { strpizzatype = "medium"; cost = 7.00; } if (rdosmall.isSelected()) { strpizzatype = "small"; cost = 5.00; } if (checkdel.isSelected()) { quantity = cost * quantity + delivery; } if (checkup.isSelected()) { quantity = cost * quantity; } if (chkgar.isSelected()) { quantity = garlic + cost; } try{ displaybox.append('\n' + "Your name : " + strname + '\n' + "Address : " + straddress + '\n' + "Pizza type : " + strpizzatype + '\n' + "Pizza cost: $ " + cost + '\n' + "Your total : $ " + quantity + '\n' + "Your Pizza will be ready in 15 minutes" ); //create a file object File output = new File("c:\\Temp\\","app.txt"); //create a file string that will write to a text file //on line at a time BufferedWriter outFile = new BufferedWriter(new FileWriter (output.getPath(), true)); outFile.write('\n' + "Your name : " + strname + '\n' + "Pizza type : " + strpizzatype + '\n' + "Pizza cost: $ " + cost + '\n' + "Your total : $ " + quantity + '\n' + "Your Pizza will be ready in 15 minutes"); //use the newLine() of the bufferedWriter class to force //a new line to be saved in the external file outFile.newLine(); //close file stream outFile.close(); JOptionPane.showMessageDialog(null, "A copy of the receipt has been saved to your hard drive", " RECEIPT SAVED", JOptionPane.WARNING_MESSAGE); } catch(Exception e) { JOptionPane.showMessageDialog(null, "A copy of the receipt was unable to save to Hard drive"); } } private void txtnameActionPerformed(java.awt.event.Ac… evt) { // TODO add your handling code here: } private void checkdelActionPerformed(java.awt.event.A… evt) { // TODO add your handling code here: } private void btnClearActionPerformed(java.awt.event.A… evt) { displaybox.setText(""); txtname.setText(""); quanfield.setText(""); buttonGroup2.clearSelection(); buttonGroup1.clearSelection(); buttonGroup3.clearSelection(); } private void jMenuItem2ActionPerformed(java.awt.event… evt) { System.exit(0); } private void jMenuItem1ActionPerformed(java.awt.event… evt) { displaybox.setText(""); txtname.setText(""); quanfield.setText(""); buttonGroup2.clearSelection(); buttonGroup1.clearSelection(); buttonGroup3.clearSelection(); }Last edited by Eranga; 11-02-2010 at 05:59 AM. Reason: code tags added
- 11-02-2010, 05:12 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
i want to make it so.... when a pizza delivery check box is selected, the address text field becomes enabled to input data
There is a setEnabled() method that all JComponent instances have (including JTextField). You could listen for events on the check box and use this method to enable/disable the text field.
- 11-02-2010, 11:26 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
thank you
thanks for that worked well, changed it to editable though
just had in my delivery checkbox code addressfield.setEditable(true)
and for the pickup addressfield.setEditable(false)
- 11-02-2010, 11:43 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Similar Threads
-
netBeans in java
By venkatesansan in forum AWT / SwingReplies: 3Last Post: 10-27-2010, 02:42 PM -
? Java Netbeans
By pottsmgg in forum New To JavaReplies: 1Last Post: 09-14-2010, 04:07 PM -
Using Netbeans for JAVA Web
By Debojit1986 in forum New To JavaReplies: 3Last Post: 03-15-2010, 05:01 PM -
About NetBeans(java)
By tiger100plus in forum New To JavaReplies: 1Last Post: 11-08-2008, 04:33 PM -
Java 3D In Netbeans
By nvidia in forum NetBeansReplies: 1Last Post: 04-09-2008, 05:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks