Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Output Help

  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Output Help

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

  • #2
    New Coder
    Join Date
    Sep 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    " inventory = getImage(getDocumentBase(), "invontory.gif"); "

    im not sure about the output part, but the reason it might not be working is that you are calling the image "invontory.gif". correct me if im wrong but should it not be "inventory.gif"? that little spelling error might be whats going wrong in the applet.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •