Need Help w/ Java Applet Program

Hello, first time on fourms. I've taken one year of Java(Poorly instructed) and I am currently trying to build a simple program, my brother is a really good gymnast so the object of this program is two drop down menus with selections, and based on the selections, an output. It has been a while since i've done anything, i've looked for reference at old work i've done and I just have gotten lost, I just need a few pointers. I'm also having compile problems such as, "Cannot find symbol", it is frustrating me, any help would be greatly appreciated!

Here is what i've got so far, based on the above "requirements" can anyone help me out? PS. The odd names I gave them are based on another similar program I wrote a while back. Thanks again!

import javax.swing.*;

import javax.swing.border.*;

import java.awt.*;

import java.awt.event.*;

import java.lang.*;

public class gymnastics extends JFrame

{

private JComboBox equationTypeComboBox;

private JComboBox equationTypeComboBox2;

private JTextField answerTextField;

public gymnastics()

{

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setUpInfoPanel();

setUpInfoPanel2();

setUpEquationPanel();

setSize(300,340);

answerTextField.requestFocus();

}

private void setUpInfoPanel()

{

JPanel infoPanel = new JPanel();

infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS));

JPanel typePanel = new JPanel();

typePanel.add(new JLabel("Event type: "));

equationTypeComboBox = new JComboBox("Floor", "Pommel", "Vault", "Rings", "PBars", "High Bar");

typePanel.add(equationTypeComboBox);

infoPanel.add(typePanel);

getContentPane().add(infoPanel, BorderLayout.NORTH);

}

private void setUpInfoPanel2()

{

JPanel infoPanel2 = new JPanel();

infoPanel2.setLayout(new BoxLayout(infoPanel2, BoxLayout.Y_AXIS));

JPanel typePanel = new JPanel();

typePanel2.add(new JLabel("Group Code: "));

equationTypeComboBox2 = new JComboBox("I","II","III","IV","V");

typePanel.add(equationTypeComboBox2);

infoPanel.add(typePanel);

getContentPane().add(infoPanel2, BorderLayout.CENTER);

}

public void setUpEquationPanel();

{

equationPanel.add(new JLabel("Output: "));

answerTextField = new JTextField();

answerTextField = ("Test Output");

equationPanel.add(answerTextField);

getContentPane().add(equationPanel, BorderLayout.SOUTH);

}

public static void main(String args[])

{

new gymnastics().setVisible(true);

}

}

[2702 byte] By [Stemmana] at [2007-11-27 5:18:32]
# 1

When you post code on these forums, please wrap it in [code][/code] tags, so it'll be easier to read.

If you have compile errors, then read the error message carefully. It will tell you what's wrong, or at least what the compiler thinks is wrong, which is usually close enough to help you figure out the problem. The error message will also give you a line number where the problem is.

Don't fall into the newbie trap of panicking when you get an error message. It's part of the process. Use the error message to fix your code and move on.

"Cannot find symbol" means that you used an identifier without declaring it first. The error message should give you more details, such as what symbol it was exactly.

paulcwa at 2007-7-12 10:41:42 > top of Java-index,Java Essentials,Java Programming...
# 2

Sorry about the code problem and thanks for the encouragement, it is just a bit frustrating at times.

import javax.swing.*;

import javax.swing.border.*;

import java.awt.*;

import java.awt.event.*;

import java.lang.*;

public class gymnastics extends JFrame

{

private JComboBox equationTypeComboBox;

private JComboBox equationTypeComboBox2;

private JTextField answerTextField;

public gymnastics()

{

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setUpInfoPanel();

setUpInfoPanel2();

setUpEquationPanel();

setSize(300,340);

answerTextField.requestFocus();

}

private void setUpInfoPanel()

{

JPanel infoPanel = new JPanel();

infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS));

JPanel typePanel = new JPanel();

typePanel.add(new JLabel("Event type: "));

equationTypeComboBox = new JComboBox("Floor", "Pommel", "Vault", "Rings", "PBars", "High Bar");

typePanel.add(equationTypeComboBox);

infoPanel.add(typePanel);

getContentPane().add(infoPanel, BorderLayout.NORTH);

}

private void setUpInfoPanel2()

{

JPanel infoPanel2 = new JPanel();

infoPanel2.setLayout(new BoxLayout(infoPanel2, BoxLayout.Y_AXIS));

JPanel typePanel = new JPanel();

typePanel2.add(new JLabel("Group Code: "));

equationTypeComboBox2 = new JComboBox("I","II","III","IV","V");

typePanel.add(equationTypeComboBox2);

infoPanel.add(typePanel);

getContentPane().add(infoPanel2, BorderLayout.CENTER);

}

public void setUpEquationPanel();

{

equationPanel.add(new JLabel("Output: "));

answerTextField = new JTextField();

answerTextField = ("Test Output");

equationPanel.add(answerTextField);

getContentPane().add(equationPanel, BorderLayout.SOUTH);

}

public static void main(String args[])

{

new gymnastics().setVisible(true);

}

}

Stemmana at 2007-7-12 10:41:42 > top of Java-index,Java Essentials,Java Programming...
# 3

You should also indent the code in a standard way, to indicate the code's structure. Also follow Java naming conventions; class names should start with an upper-case letter, and almost everything else starts with a lower-case letter.

Anyway, do you have any problems at this point? If there's a precise error message that you don't understand or can't solve, then post it here (don't just paraphrase it, copy the full error message into your post), and tell us what problem you're having with it.

paulcwa at 2007-7-12 10:41:42 > top of Java-index,Java Essentials,Java Programming...
# 4

Looks like you use a lot of incorrect parameters for each constructor. For instance your JComboBox takes in vectors/arrays. You're passing it several strings which is not an array.

Also, it looks like some of your variables are out of scope.

Other's you've never even declared and you try to use them. For instance some of the JPanels don't even exist. Yet you use the .add(blah) methods for them.

lethalwirea at 2007-7-12 10:41:42 > top of Java-index,Java Essentials,Java Programming...