home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

calculation in GUI problem

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1462
Discussions: 200,906, Posts: 2,378,908, Members: 246,276
Old November 5th, 2009, 11:46 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Nov 2009
Posts: 1
calculation in GUI problem

hye..i'm newbie...plz help me..i have problem with calculation in this subclass
what problem i counter is the result i want appear in receipt was not appear..that is 8 field in the receipt..Name,address,Hp.no,Pizza type,size,Quantity,side order and total price..for now what just appear is name,address and hp no..the other i don't know why not appear..and the big problem is about total price..i have insert the price side of the item but that not appear also..thank so much if somebody can help me..this a subclass code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.ActionListener.*;

public class Form extends JFrame implements ActionListener{

private JTextField jtfname,jtfaddress,jtfnotel,jtfquan,jlabName,jlabA dd,jlabtel,jlabtype,jlabquan,jlabsize,jlabside,jla bprice;
private JButton jbtconfirm,jbtmainmenu;
private JCheckBox jcbCW,jcbMS,jcbS,jcbCL,jcbC,jcbB;
private JRadioButton jrbSmall,jrbRegular,jrbLarge,jrbex,jrbalo;


public Form(){

//Create a new panel to hold label and text field
JPanel p1 = new JPanel(new FlowLayout());
p1.setBorder(new TitledBorder("CUSTOMER'S DETAILS"));
p1.setLayout(new GridLayout(5,2));
p1.add(new JLabel("Name:"));
p1.add(jtfname= new JTextField(3));
p1.add(new JLabel("Address:"));
p1.add(jtfaddress= new JTextField(3));
p1.add(new JLabel("No Tel:"));
p1.add(jtfnotel= new JTextField(3));
//Receipt
JPanel receipt = new JPanel(new FlowLayout());
receipt.setBorder(new TitledBorder("YOUR RECEIPT"));
receipt.setLayout(new GridLayout(8,2));
receipt.add(new JLabel("Name:"));
receipt.add(jlabName = new JTextField(8));
receipt.add(new JLabel("Address:"));
receipt.add(jlabAdd = new JTextField(8));
receipt.add(new JLabel("HP.No:"));
receipt.add(jlabtel = new JTextField(8));
receipt.add(new JLabel("Pizza's type:"));
receipt.add(jlabtype = new JTextField(8));
receipt.add(new JLabel("Size:"));
receipt.add(jlabsize = new JTextField(8));
receipt.add(new JLabel("Quantity:"));
receipt.add(jlabquan = new JTextField(8));
receipt.add(new JLabel("Side Order:"));
receipt.add(jlabside = new JTextField(8));
receipt.add(new JLabel("Total price:"));
receipt.add(jlabprice = new JTextField(8));

/*jlabName.setHorizontalAlignment(JTextField.RIGHT) ;
jlabAdd.setHorizontalAlignment(JTextField.RIGHT);
jlabtel.setHorizontalAlignment(JTextField.RIGHT);
jlabtype.setHorizontalAlignment(JTextField.RIGHT);
jlabsize.setHorizontalAlignment(JTextField.RIGHT);
jlabquan.setHorizontalAlignment(JTextField.RIGHT);
jlabside.setHorizontalAlignment(JTextField.RIGHT);
jlabprice.setHorizontalAlignment(JTextField.RIGHT) ;*/

jlabName.setEditable(false);
jlabAdd.setEditable(false);
jlabtel.setEditable(false);
jlabtype.setEditable(false);
jlabsize.setEditable(false);
jlabquan.setEditable(false);
jlabside.setEditable(false);
jlabprice.setEditable(false);
receipt.setBackground(Color.orange);
//add the component
Container container = getContentPane();
container.add(p1,BorderLayout.NORTH);
container.add(receipt,BorderLayout.SOUTH);

//add radio button
JPanel p2= new JPanel();
p2.setBorder(new TitledBorder("TYPE OF PIZZA"));
p2.setLayout(new GridLayout(8,2));
ButtonGroup sizeGroup=new ButtonGroup();

jrbex=new JRadioButton("Extravaganza RM23.80");
jrbex.setSelected(true);
p2.add(jrbex);
sizeGroup.add(jrbex);

jrbalo=new JRadioButton("Aloha Chicken RM23.80");
p2.add(jrbalo);
sizeGroup.add(jrbalo);
container.add(p2,BorderLayout.WEST);

//put check box
JPanel p3 = new JPanel(new FlowLayout());
p3.setLayout(new GridLayout(8,2));
p3.add(jcbCW=new JCheckBox("Chicken Wings RM2.99"));
p3.add(jcbMS=new JCheckBox("Mushroom Soup RM2.99"));
p3.add(jcbS=new JCheckBox("Spaghetti RM5.00"));
p3.add(jcbCL=new JCheckBox("Chicken Lasagna RM3.00"));
p3.add(jcbC=new JCheckBox("Coleslaw RM2.00"));
p3.add(jcbB=new JCheckBox("Breadstick RM2.00"));
p3.setBorder(new TitledBorder("SIDE ORDER"));
getContentPane().add(p3,BorderLayout.EAST);
//Set mnemonic keys for ceck box and radio button
jcbCW.setMnemonic('W');
jcbMS.setMnemonic('M');
jcbS.setMnemonic('S');
jcbCL.setMnemonic('L');
jcbC.setMnemonic('C');
jcbB.setMnemonic('B');

//add radio button
JPanel p4= new JPanel();
p4.setBorder(new TitledBorder("SIZE OF PIZZA"));
p4.setLayout(new GridLayout(7,2));
ButtonGroup sizeGroup2=new ButtonGroup();

jrbSmall=new JRadioButton("Small");
jrbSmall.setSelected(true);
p4.add(jrbSmall);
sizeGroup2.add(jrbSmall);

jrbRegular=new JRadioButton("Regular");
p4.add(jrbRegular);
sizeGroup2.add(jrbRegular);

jrbLarge=new JRadioButton("Large");
p4.add(jrbLarge);
sizeGroup2.add(jrbLarge);
jrbSmall.setSelected(true);

p4.add(new JLabel("QUANTITY:"));
p4.add(jtfquan= new JTextField(1));
jtfquan.setHorizontalAlignment(JTextField.RIGHT);
//ok and menu button

p4.add(jbtconfirm=new JButton("CONFIRM ORDER"));
p4.add(jbtmainmenu=new JButton("MAIN MENU"));
//Register button listener
jbtconfirm.addActionListener(this);
jbtmainmenu.addActionListener(this);

container.add(p4,BorderLayout.CENTER);






}
public void actionPerformed(ActionEvent e)
{

if (e.getSource() == jbtconfirm)
{
String name = jtfname.getText();
jlabName.setText(String.valueOf(name));
String address = jtfaddress.getText();
jlabAdd.setText(String.valueOf(address));
String tel = jtfnotel.getText();
jlabtel.setText(String.valueOf(tel));
String type =jlabtype.getInputContext();
jlabtype.setText(String.valueOf(type));



}
if (e.getSource() == jbtmainmenu)
{
secondpage frame = new secondpage();
frame.setTitle("Main Menu");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setSize(400,400);
frame.setLocation(450,170);
frame.setVisible(true);
this.dispose();
}

}



/* // Main method
public static void main(String[] args) {
Form frame = new Form();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setTitle("ORDER FORM");
frame.setSize(600, 600);
frame.setVisible(true);

}*/

}
forceblogger is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
calculation off by 1 :( ShuckyD Webmastering and Programming 6 February 15th, 2007 07:40 PM
Windows XP Safe Mode problem: no desktop/ no GUI jxcheng Applications and Operating Systems 2 August 4th, 2006 09:24 PM
Asteroid Calculation Program phenious IMO Community 0 April 13th, 2004 04:38 PM
best processor for calculation? fcitori Processors, Memory, and Overclocking 3 March 16th, 2004 10:40 AM
Gui in VC++ or C++ amtrac24 Webmastering and Programming 1 October 3rd, 2003 04:06 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2809)
Is the PSU I received dead? (10)
California Passes Anti-Flat-HDTV Le.. (38)
Install XP pro and a Vista laptop ?.. (8)
Fox uses old news clips to inflate .. (33)
A good PSU? (10)
HIS HD5770 graphic card question (14)
Foreign voltage (6)
New Computer wont recognize XP disc (7)
Dept. of HS: NSA 'Helped' Develop V.. (12)
Ideal cheap graph card for PC-Gamin.. (15)
Print spooler problem (5)
EVGA 9800 gtx help with finding a g.. (6)
Modern Warfare 2: Who Bought It? (60)
Recent Discussions
Need hard disk drivers (4)
Asus P4G8X Mobo (1)
windows 7 internet problem (4)
windows vista security holes (1)
What OS for a home server? (other tha.. (1)
Boot Problem? (0)
Logitech G9 laser gaming mouse $59.95.. (2)
$5 off any item with the purchase of .. (1)
Foreign voltage (6)
Ideal cheap graph card for PC-Gaming? (15)
HIS HD5770 graphic card question (14)
Install XP pro and a Vista laptop ?? (8)
Cloning old drive to new drive (6)
Amptron monitor G17FP-Black (0)
EVGA 9800 gtx help with finding a goo.. (6)
A good PSU? (10)
Is the PSU I received dead? (10)
HP Pavillion Laptop ze4220 won't turn.. (7)
Dept. of HS: NSA 'Helped' Develop Vis.. (12)
Convert 5 pin Keyboard to USB (11)
Print spooler problem (5)
hybernate option (2)
Steam ID's, Gamertags etc... (1)
New Computer wont recognize XP disc (7)
World's largest Monopoly Game using G.. (328)


All times are GMT -4. The time now is 08:27 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28