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.....
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();
}
