0

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);
			  }
		  }
		}
	}
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by mKorbel
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.