Advertisement Jump to content
Sign in to follow this  

java identifer expected?

This topic is 4659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys I am trying to build a simple applet and am having enormous difficulty... I am purposefully trying to do AWAY with the layout manager (for now at least) so I can manually set the location of my controls. Here is my code:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JApplet.*;

public class MathEngine extends JApplet implements ActionListener
	private static final long serialVersionUID = 1L;

	// Disable the default layout manager.

	// Global child controls.
	JLabel inputQuestion;
	JLabel answer;
	JButton solve;
	JTextField input;
	JTextField output;
	JButton pi;
	JButton e;
	JButton img;

	public void init()
		// Define the controls.
		inputQuestion = new JLabel("Input Question :");
		answer = new JLabel("Answer :");
		solve = new JButton("SOLVE!");
		input = new JTextField(30);
		output = new JTextField(30);
		pi = new JButton("PI");
		e = new JButton("e");
		img= new JButton("IMG");

		// Add them to the screen.
		this.add(inputQuestion); this.add(answer); this.add(solve);
		this.add(input); this.add(output); this.add(pi); this.add(e);

		// Register an action listener for the SOLVE! JButton.

		// Place the controls on the screen.
		Dimension temp;

                // The rest of this code just re-assigns 'temp' to each control,
                // queries the control with 'getPreferredSize()' and then uses
                // the Dimension to 'setBounds()' -- which is where I want the
                // control located. It's really not important.

	public void start() {}
	public void stop() {}
	public void destroy() {}

	public void actionPerformed(ActionEvent ae)
		Object source = ae.getSource();

		if(source == this.solve)
                    // Do something

I am getting identifer expected and illegal start of type errors for line #17: this.setLayout(null); I don't get this compilation error in other applets where I do the same exact thing? WTF??

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!