tootall2
10-22-2004, 02:46 AM
I had a question. I want to display output for my program but im not sure that im doing it correctly becaue when I run my Applet it doesnt show the input the user writes. . The output is in the code below. it is outputLabel.setText("YOUR INVENTORY IS" + enterLabel + numberLabel);
Heres my code
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class InventoryApplet extends Applet implements ActionListener
{
//declaring Variables
String income, dependents;
Image inventory;
//construct coponents
Label companyLabel = new Label("A-Z INVENTORY PROGRAM");
Label incomeLabel = new Label("Enter Inventory:");
TextField incomeField = new TextField(10);
Label dependentsLabel = new Label("Quanity:");
TextField dependentsField = new TextField(10);
Button calcButton = new Button("Add to List");
Label enterLabel = new Label("Enter Inventory");
TextField enterField = new TextField(10);
Label numberLabel = new Label("Enter Quanity");
TextField numberField = new TextField(10);
Button enterbutton = new Button("Find");
Label outputLabel = new Label("YOUR INVENTORY IS" + enterField + numberField);
public void init()
{
setBackground(Color.gray);
setForeground(Color.white);
incomeField.setForeground(Color.blue);
dependentsField.setForeground(Color.blue);
enterField.setForeground(Color.blue);
add(companyLabel);
add(incomeLabel);
add(incomeField);
add(dependentsLabel);
add(dependentsField);
add(calcButton);
add(enterLabel);
add(enterField);
add(numberLabel);
add(numberField);
add(enterbutton);
calcButton.addActionListener(this);
add(outputLabel);
inventory = getImage(getDocumentBase(), "invontory.gif");
}
public void actionPerformed(ActionEvent e)
{
}
public void paint(Graphics g)
{
g.drawImage(inventory,125,160,this);
}
}
Heres my code
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class InventoryApplet extends Applet implements ActionListener
{
//declaring Variables
String income, dependents;
Image inventory;
//construct coponents
Label companyLabel = new Label("A-Z INVENTORY PROGRAM");
Label incomeLabel = new Label("Enter Inventory:");
TextField incomeField = new TextField(10);
Label dependentsLabel = new Label("Quanity:");
TextField dependentsField = new TextField(10);
Button calcButton = new Button("Add to List");
Label enterLabel = new Label("Enter Inventory");
TextField enterField = new TextField(10);
Label numberLabel = new Label("Enter Quanity");
TextField numberField = new TextField(10);
Button enterbutton = new Button("Find");
Label outputLabel = new Label("YOUR INVENTORY IS" + enterField + numberField);
public void init()
{
setBackground(Color.gray);
setForeground(Color.white);
incomeField.setForeground(Color.blue);
dependentsField.setForeground(Color.blue);
enterField.setForeground(Color.blue);
add(companyLabel);
add(incomeLabel);
add(incomeField);
add(dependentsLabel);
add(dependentsField);
add(calcButton);
add(enterLabel);
add(enterField);
add(numberLabel);
add(numberField);
add(enterbutton);
calcButton.addActionListener(this);
add(outputLabel);
inventory = getImage(getDocumentBase(), "invontory.gif");
}
public void actionPerformed(ActionEvent e)
{
}
public void paint(Graphics g)
{
g.drawImage(inventory,125,160,this);
}
}