954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

GUI Trouble

Hey everyone, I am writing a GUI that allows a person to enter all their own numbers into an array, then they can search the array for any number they want. I have it almost completely written except for two compile errors I can't figure out

The first one is on line 40 saying "cannot resolve symbol" pointing at "fin"
The second one is on line 49 saying the same thing pointing at "fin"
any help is greatly appreciated, thanks in advance.

import javax.swing.*;
import BreezySwing.*;

public class array extends GBFrame
{
 private JLabel ArrayLengthLabel;
 private JLabel DataEntryLabel;
 private JLabel TargetValueLabel;
 private IntegerField ArrayLengthField;
 private IntegerField DataEntryField;
 private IntegerField TargetValueField;
 private JButton SetLengthButton;
 private JButton InsertDataButton;
 private JButton SearchButton;
 int count = 0;
 int search;

	public array()
	{
	  ArrayLengthLabel = addLabel ("Array Length" ,1,1,1,1);
	  DataEntryLabel = addLabel ("Data Entry" ,1,2,1,1);
	  TargetValueLabel = addLabel ("Target Value" ,1,3,1,1);
	  ArrayLengthField = addIntegerField (0 ,2,1,1,1);
	  DataEntryField = addIntegerField (0 ,2,2,1,1);
	  TargetValueField = addIntegerField (0 ,2,3,1,1);
	  SetLengthButton = addButton ("Set Length" ,3,1,1,1);
	  InsertDataButton = addButton ("Insert Data" ,3,2,1,1);
	  SearchButton = addButton ("Search" ,3,3,1,1);
	}

	public void buttonClicked(JButton buttonObj)
	{
		if(buttonObj == SetLengthButton)
		{
		  int[] fin = new int[ArrayLengthField.getNumber()];
		}
		
		else if(buttonObj == InsertDataButton)
		{
		  fin[count] = DataEntryField.getNumber();
		  count++;
		}
		
		else if(buttonObj == SearchButton)
		{
		  search = TargetValueField.getNumber();
		  for(int i = 0; i < 10; i++)
		  {
		  	if(search == fin[i])
			  {
			  	messageBox(search+ "is found at position" +i);
			  }
		  }
		}
	}
}
MrHardRock
Light Poster
41 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

JLabel isn't for userInput look for JTextField, but for Number is better to look for http://download.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html with Number formatter allows to input only numbers


and lots of another newbee mistakes

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: