can you tell me what i should be sending:
/*
* 1. Number of Pieces
* 2. Finished Dimensions = T" x W" x L"
* 3. Rough Dimensions= T" x (W"+1/2") x (L"+1")
* 4. Kind of Material - The type of wood
* 5. BD. SQFT. = Plywood Formula=((Number of Pieces) x W" x L")/144
*Lumber Formula =((Number of Pieces) x (Finished Dimensions))/144
* 6. Cost/FT.
* 7. Cost = BD. SQFT x Cost/FT. = Cost
* 8. Supply Factor = $1.35
* 9. Tax = 1.065
* 10. Total
*/
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;
import java.text.DecimalFormat;
public class Start
{
DecimalFormat df;
JFrame f1;
JTextField Pieces,FDTt,FDTw,FDTl;
JButton Calculate, Finish, Cancel, Add;
JPanel p1,p2,p3,p4,p5,p6,p7,p8;
JLabel piece, fd, rd, m, a, b, sf, t, tc,Disclaimer,cost,BDFT,FCost;
Container c1;
String RtS,RwS,RlS,pS,Selected,selection,totals,ans4;
double Supply=1.35;
double Tax=1.065;
double T,W,L,A,B,C,BDFTL,Total,p;
int remember,xx=0;
double c=0;
double d=0;
double ans3=0;
double ans=0;
double ans2=0;
int No=0;
String[] names;
ArrayList woodlist,Receipt;
String [] type = {"Plywood","Lumber","-"};
JComboBox Type = new JComboBox(type);
JLabel HEY;
Start st;
Project P;
String material;
public Start(ArrayList wd, double To)
{
woodlist = new ArrayList();
woodlist = wd;
Receipt= new ArrayList();
restofconstruct();
Total=To;
}
public Start(ArrayList wd, double To, ArrayList rcpt)
{
woodlist = new ArrayList();
woodlist = wd;
Receipt=new ArrayList();
Receipt=rcpt;
Total=To;
restofconstruct();
}
public void restofconstruct()
{
df = new DecimalFormat("0.##");
HEY = new JLabel();
JPanel content = new JPanel(new GridLayout(15,1));
content.add(new JLabel("For the dimensions,"));
content.add(new JLabel(" you'll have to use INCHES"));
content.add(new JLabel(""));
content.add(new JLabel(" No. of Pieces"));
content.setBackground(Color.white);
p3= new JPanel();
p3.setBackground(Color.white);
content.add(p3);
Pieces = new JTextField(2);
Pieces.setText("0");
p3.add(Pieces);
content.add(new JLabel(" Finished Dimensions"));
p2=new JPanel();
p2.setBackground(Color.white);
content.add(p2);
FDTt= new JTextField(3);
FDTt.setText("0");
FDTw= new JTextField(3);
FDTw.setText("0");
FDTl= new JTextField(3);
FDTl.setText("0");
p2.add(FDTt);
p2.add(FDTw);
p2.add(FDTl);
content.add(new JLabel("Kind of Material"));
p4 = new JPanel();
p4.setBackground(Color.white);
//Combo Box
names = new String[woodlist.size()+1];
for (int x = 0;x<woodlist.size();x++)
{
names[x]=((Wood)(woodlist.get(x))).getName();
xx=x;
}
names[xx+1]="-";
JComboBox Woods = new JComboBox(names);
Woods.setSelectedIndex(woodlist.size()-0);
Woods.addActionListener(new MenuListener());
Type.setSelectedIndex(2);
Type.addActionListener(new WoodListener());
p4.add(Type);
p4.add(Woods);
content.add(p4);
content.add(new JLabel("BD FT./ SQ. FT."));
BDFT = new JLabel("");
content.add(BDFT);
content.add(new JLabel("Cost/Foot"));
cost=new JLabel("");
content.add(cost);
content.add(new JLabel("Cost"));
FCost = new JLabel("");
content.add(FCost);
JPanel Buttons = new JPanel(new GridLayout(3,1));
Buttons.setBackground(Color.white);
Buttons.add(HEY);
Finish = new JButton(" Finish ");
Finish.addActionListener(new ButtonListener());
Cancel = new JButton(" Cancel ");
Cancel.addActionListener(new ButtonListener());
Add = new JButton(" Add Another Piece");
Add.addActionListener(new ButtonListener());
Buttons.add(Add);
Buttons.add(new JLabel(""));
Buttons.add(new JLabel(""));
Buttons.add(Finish);
Buttons.add(new JLabel(" "));
Buttons.add(new JLabel(""));
Buttons.add(Cancel);
f1 = new JFrame(" Bill of Materials & Stock Cutting List ");
f1.setSize(1000,1000);
f1.addKeyListener(new UpdateListener());
p1 = new JPanel();
p1.setBackground(Color.white);
c1 = f1.getContentPane();
sf = new JLabel("Supply Factorx $1.35");
t = new JLabel(" Tax x 6.5%");
tc = new JLabel("Total Cost");
p1.add(content);
p1.add(new JLabel(" "));
p1.add(Buttons);
p1.add(HEY);
c1.add(p1);
//Center frame
f1.show();
}
public void calculate (double c)
{
c=c;
pS= Pieces.getText();
p=Double.parseDouble(pS);
if (FDTt==null )
T=0;
else
{
RtS=FDTt.getText();
T=Double.parseDouble(RtS);
}
if (FDTw==null)
W=0;
else
{
RwS=FDTw.getText();
W=Double.parseDouble(RwS);
}
if (FDTl==null)
L=0;
else
{
RlS=FDTl.getText();
L=Double.parseDouble(RlS);
}
if (Selected.equals("Plywood"))
{
material="Plywood";
RwS=FDTw.getText();
W=Double.parseDouble(RwS);
RlS=FDTl.getText();
L=Double.parseDouble(RlS);
pS=Pieces.getText();
No=Integer.parseInt(pS);
ans = (No * (1+W) *(.5+L))/144;
String ans2=df.format(ans);
BDFT.setText(ans2);
d=1;
}
if (Selected.equals("Lumber"))
{
material ="Lumber";
RtS=FDTt.getText();
T=Double.parseDouble(RtS);
RwS=FDTw.getText();
W=Double.parseDouble(RwS);
RlS=FDTl.getText();
L=Double.parseDouble(RlS);
pS=Pieces.getText();
No=Integer.parseInt(pS);
ans=(No*T*(1+W)*(1+L))/144;
String ans2=df.format(ans);
BDFT.setText(""+ans2);
d=1;
}
if (Selected.equals("-"))
{
BDFT.setText("Please select the kind of wood you'd like to use ");
d=0;
}
ans3=(ans*c);
ans4 = df.format(ans3);
FCost.setText(""+ans4);
}
private class UpdateListener implements KeyListener
{
public void keyPressed(KeyEvent event)
{
calculate(c);
}
public void keyReleased(KeyEvent event)
{}
public void keyTyped(KeyEvent event)
{}
}
private class WoodListener implements ActionListener
{
public void actionPerformed (ActionEvent select)
{
JComboBox twood = (JComboBox)select.getSource();
Selected = (String)twood.getSelectedItem();
calculate(c);
}
}
private class MenuListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
JComboBox cb = (JComboBox)event.getSource();
selection = (String)cb.getSelectedItem();
remember=-1;
for (int x = 0;x<woodlist.size();x++)
{
if (selection.equals(((Wood)woodlist.get(x)).getName()))
remember=x;
}
if (remember==-1)
c=0;
else
{
Wood w =(Wood)(woodlist.get(remember));
c= w.getCost();
}
if (c==0)
{
c=0;
cost.setText("Please select the material you'd like to use ");
}
else
cost.setText(""+c);
calculate(c);
}
}
private class ButtonListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
if (event.getSource()== Finish)
{
f1.dispose();
Total=Total+ans3;
RtS=FDTt.getText();
T=Double.parseDouble(RtS);
RwS=FDTw.getText();
W=Double.parseDouble(RwS);
RlS=FDTl.getText();
L=Double.parseDouble(RlS);
pS=Pieces.getText();
No=Integer.parseInt(pS);
if ((material!=null)||(No!=0))
{
P=new Project(No,T,W,L,material,ans,names);
Receipt.add(P);
}
Save_Receipt s = new Save_Receipt(Receipt);
s.save_receipt();
Final_Receipt r = new Final_Receipt(Receipt);
}
if (event.getSource()== Cancel)
{
f1.dispose();
Start_Menu sm = new Start_Menu();
}
if (event.getSource()== Add)
{
if (d==0)
{
HEY.setText("Hey, you don't have a type of wood selected!!");
}
if ((int)c==0)
{
HEY.setText("Hey, you don't have a material selected!!");
}
if ((d==0)&&((int)c==0))
{
HEY.setText("Hey, you don't have a type of wood selected and no material selected!!");
}
if ((d!=0)&&(c!=0))
{
// totals= FCost.getText();
// Total=Double.parseDouble(totals);
Total=Total+ans3;
P=new Project(No,T,W,L,material,ans,names);
Receipt.add(P);
// System.out.println(Receipt.get(0));
st = new Start(woodlist,Total,Receipt);
f1.dispose();
}
}
}
}
}
>
Assuming you have got a mechanism in that 'other class' to receive it you could instantiate that other class and use one of it's methods to 'set' the variable in that class; or if it's a member that is determined to be a static member in that 'other' class then you could just call a static 'set' method in it. For example, suppose the variable is held as a String, named goofBall, and suppose that 'other' class is called OtherClass. Further suppose that OtherClass has a setGoofBall(String _goofBall) method. Then you'd:
OtherClass ot = new OtherClass();
ot.setGoofBall(goofBall);
Then in the OtherClass, you'd proceed ...
public void setGoofBall(String _goofBall);
goofBall = _goofBall;
}
Okay?