3 Replies - 996 Views - Last Post: 17 March 2013 - 03:48 PM Rate Topic: -----

#1 blewittdot3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-March 13

Can't get program to compile. Also want to populate form.

Posted 17 March 2013 - 03:00 PM

I'm trying to create a form that will display TextArea's and a button. I'm trying to call the object method from the main but its not compiling and telling me "cannot find symbol" and then pointing to the Output label in the main method. What can I do to get this to compile and display the TextArea and button.

Also, all I want help with is getting the program to compile and populate the form. Everything else I can work on at a later time so please don't rip the code for being horrible I'm still a beginner.

Thanks


import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;

public class SkydiveSimple extends Frame implements ActionListener
{
	int counter, random;
	int count = 0;
	int points = 0;
	int[] formation = new int[5];

	Panel formationPanel = new Panel();
		TextArea formationDisplay[] = new TextArea[5]; //There can be no more than five formations generated

	Panel buttonPanel = new Panel();
		Button generateButton = new Button("Generate Set");


	public void Output()
	{
		//set layouts for frame and panels
		this.setLayout(new BorderLayout());
			formationPanel.setLayout(new GridLayout(1,5,10,10));
			buttonPanel.setLayout(new FlowLayout());


		//add components to set panel
		for(int counter=1; counter<4; counter = counter + 1);
		{
			formationDisplay[counter] = new TextArea(null,3,5,3);
			formationDisplay[counter].setText("" + formation);
			formationDisplay[counter].setEditable(false);
			formationPanel.add(formationDisplay[counter]);
		}

		//add components to button panel
		buttonPanel.add(generateButton);


		//add panels to frame
		add(buttonPanel, BorderLayout.SOUTH);
		add(formationPanel, BorderLayout.CENTER);

		generateButton.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		while(points > 5)
			{
				Random generator = new Random();
				random = generator.nextInt(31) + 1;
				formation[count] = random;
				if (random < 27) points = (points + 2);
				else points = (points + 1);
			}

	}

	public static void main(String[] args)
	{
		SkydiveSimple f = new Output();
		f.setBounds(200, 200, 600, 300);
		f.setTitle("Skydive Simple");
		f.setVisible(true);
	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Can't get program to compile. Also want to populate form.

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: Can't get program to compile. Also want to populate form.

Posted 17 March 2013 - 03:06 PM

The statement "new Output()" is how a new object is created using the object's constructor. Calling a method looks like:

variable = thisMethodResult();

If Output() is supposed to be the constructor, then the class should be called Output, and the constructor signature should not have a return type, not even void.
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3487
  • View blog
  • Posts: 15,766
  • Joined: 20-September 08

Re: Can't get program to compile. Also want to populate form.

Posted 17 March 2013 - 03:47 PM

Are you using AWT gui components for a reason? If, so, perhaps better not to mix them up with Swing JOptionPane
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12210
  • View blog
  • Posts: 45,289
  • Joined: 27-December 08

Re: Can't get program to compile. Also want to populate form.

Posted 17 March 2013 - 03:48 PM

Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1