class. interface, or enum expected

"class. interface, or enum expected" error occurs during com

Page 1 of 1

3 Replies - 2393 Views - Last Post: 05 August 2009 - 07:37 AM Rate Topic: -----

#1 tenec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 22-February 09

class. interface, or enum expected

Posted 04 August 2009 - 01:35 PM

I receive the "class. interface, or enum expected" error when I try to compile. I get 53 of these errors on 53 different lines of my code. Usually this means that you forgot or mis-spelled one or more words in your program. I have thoroughly checked my code and it seems fine, but it won't compile.

could someone take a look and see if you can figure out what I'm obviously overlooking??

 
importjava.awt.GridLayout;
importjava.awt.BorderLayout;
importjava.awt.FlowLayout;
importjavax.swing.JFrame;
importjavax.swing.JButton;
importjavax.swing.JTextField;
importjavax.swing.JCheckBox;
importjavax.swing.JLabel;
importjavax.swing.JPanel;

public class AlignFrame extends JFrame
{
	private JButton okJButton;
	private JButton cancelJButton;
	private JButton helpJButton;
	private JTextField xJTextField;
}	private JTextField yJTextField;
	private JCheckBox snapJCheckBox;
	private JCheckBox showJCheckBox;
	private JLabel xJLabel;
	private JLabel yJLabel;
	private Jpanel checkJPanel;
	private Jpanel buttonJPanel;
	private Jpanel fieldJPanel1;
	private Jpanel fieldJPanel2;
	private Jpanel fieldJPanel;
	
	// constructor setsup GUI
	public AlignFrame()
	{
		super( "Align" );
		
		// build checkJPanel
		snapJCheckBox = new JCheckBox( "Snap to Grid" );
		showJCheckBox = new JCheckBox( "Show Grid" );
		checkJPanel = new JPanel();
		checkJPanel.setLayout( new GridLayou(2,1)); // use gridlayout
		checkJPanel.add( snapJCheckBox ); // add snap checkbox
		checkJPanel.add( showJCheckBox ); // add show checkbox
		
		// build field panel1
		xJLabel = new JLabel( "X:" );
		xJTextField = newJTextField("8", 3); // set width of textfield
		fieldJPanel1 = new JPanel();
		fieldJPanel1.setLayout(new FlowLayout()); // use flowlayout
		fieldJpanel1.add( xJLabel);
		fieldJpanel1.add( xJTextField);
		
		// build field panel2
		yLabel = new JLabel( "y:" );
		yJTextField = new JTextField("8",3); // set width of textfield
		fieldJPanel2 = new JPanel();
		fieldJPanel2.setLayout(new FlowLayout()); // use flowlayout
		fieldJpanel2.add( yJLabel);
		fieldJpanel2.add( yJTextField);
		
		// build field panel
		fieldJPanel = new JPanel();
		fieldJPanel.setLayout(new BorderLayout()); // use border layout
		fieldJpanel.add( fieldJPanel1, BorderLayout.North );
		fieldJpanel.add( fieldJPanel1, BorderLayout.North );
		
		// build field panel
		okJButton = new JButton( "Ok")
		cancelJButton = new JButton( "Cancel" )
		helpJButton = new JButton( "Help" );
		buttonJPanel = new JPanel();
		buttonJPanel.setLayout( new GridLayout(3,1,10,5)); // use gridlayout
		buttonJpanel.add( okJButton );
		buttonJpanel.add( cancelJButton );
		buttonJpanel.add( helpJButton );
		
		// use flowlayout center-aligned and add components
		setLayout( new FlowLayout( FlowLayout.Center, 10, 5));
		add( checkJPanel );
		add( fieldJPanel );
		add( buttonJPanel );
	}  // end AlignFrame constructor
} // end class Align



Is This A Good Question/Topic? 0
  • +

Replies To: class. interface, or enum expected

#2 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: class. interface, or enum expected

Posted 04 August 2009 - 01:37 PM

Well, your first problem is this
public class AlignFrame extends JFrame
{
	private JButton okJButton;
	private JButton cancelJButton;
	private JButton helpJButton;
	private JTextField xJTextField;
}


Thats where you are accidently closing your class. Remove the bottom }
Was This Post Helpful? 0
  • +
  • -

#3 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: class. interface, or enum expected

Posted 04 August 2009 - 01:52 PM

yep that's it..whenever you get this error message, just recheck your braces..that would probably be the problem
Was This Post Helpful? 0
  • +
  • -

#4 tenec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 22-February 09

Re: class. interface, or enum expected

Posted 05 August 2009 - 07:37 AM

View Postnick2price, on 4 Aug, 2009 - 12:37 PM, said:

Well, your first problem is this
public class AlignFrame extends JFrame
{
	private JButton okJButton;
	private JButton cancelJButton;
	private JButton helpJButton;
	private JTextField xJTextField;
}


Thats where you are accidently closing your class. Remove the bottom }


That did the trick.

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1