I have been troubled about my program how to put some funtionalities regarding on my buttons can anybody can help me?
In button compute I have to put some computation regarding on (weight*perounce)+others;
then for the button clear I have to clear all the inputed data in the textfield;
then for the button exit I have to exit the application/GUI;
then for the button add I have to add the data being compute in regarding of what type of package(Overnight package or Two day Packge) he/she selected, then I have to put it in a array that will be use by my button display;
In my button display if i select one or any of the two packages then it will display the list of customers who avail in that certain package..
then I have also some trouble on how can i use a autonumbering for my tracking number...and how can i drop the list in my combo box Package type....
fortunately, here are the codes that i have already finished..
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PackageGUI extends JFrame
{
private JLabel lblTrackingNo,lblName,lblAddress,lblCity,lblState,lblZipCode,lblPackageType,lblWeight,lblPerounce,lblOthers,lblPayment;
private JTextField txtTrackingNo,txtName,txtAddress,txtCity,txtState,txtZipCode,txtWeight,txtPerounce,txtOthers,txtPayment;
private JButton btnCompute,btnAdd,btnClear,btnExit;
private JComboBox PackageType,Display;
String [] packName={"Over Night Package","Two Day Package"};
String [] displayType={"Over Night Package","Two Day Package"};
private Panel p1;
private Panel p2;
public PackageGUI()
{
super("Compute per Package");
setSize(600,600);
lblTrackingNo=new JLabel("Tracking No.");
lblName=new JLabel("Name");
lblAddress=new JLabel("Address");
lblCity=new JLabel("City");
lblState=new JLabel("State");
lblZipCode=new JLabel("Zip Code");
lblPackageType=new JLabel("Package Type");
lblWeight=new JLabel("Weight");
lblPerounce=new JLabel("Per Ounce");
lblOthers=new JLabel("Others");
lblPayment=new JLabel("Payments");
txtTrackingNo=new JTextField(10);
txtName=new JTextField(10);
txtAddress=new JTextField(10);
txtCity=new JTextField(10);
txtState=new JTextField(10);
txtZipCode=new JTextField(10);
txtWeight=new JTextField(10);
txtPerounce=new JTextField(10);
txtOthers=new JTextField(10);
txtPayment=new JTextField(10);
txtPayment.setEditable(false);
PackageType=new JComboBox(packName);
Display=new JComboBox(displayType);
btnCompute=new JButton("Compute");
btnAdd=new JButton("Add");
btnClear=new JButton("Clear");
btnExit=new JButton("Exit");
p1=new Panel(new GridLayout(11,3));
p1.add(lblTrackingNo);
p1.add(txtTrackingNo);
p1.add(lblName);
p1.add(txtName);
p1.add(lblAddress);
p1.add(txtAddress);
p1.add(lblCity);
p1.add(txtCity);
p1.add(lblState);
p1.add(txtState);
p1.add(lblZipCode);
p1.add(txtZipCode);
p1.add(lblPackageType);
p1.add(PackageType);
p1.add(lblWeight);
p1.add(txtWeight);
p1.add(lblPerounce);
p1.add(txtPerounce);
p1.add(lblOthers);
p1.add(txtOthers);
p1.add(lblPayment);
p1.add(txtPayment);
p2=new Panel(new GridLayout(5,1));
p2.add(btnCompute);
p2.add(btnAdd);
p2.add(btnClear);
p2.add(btnExit);
p2.add(Display);
Container pane=getContentPane();
pane.setLayout(new FlowLayout());
pane.add(p1,BorderLayout.WEST);
pane.add(p2,BorderLayout.EAST);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
}
public static void main(String[]args)
{
PackageGUI p=new PackageGUI();
}
}