Jump to content
  • Advertisement
Sign in to follow this  
hisDudeness

java identifer expected?

This topic is 4421 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:
// IMPORTS
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JApplet.*;

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

	// Disable the default layout manager.
	this.setLayout(null);

	// 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);
                this.add(img);

		// Register an action listener for the SOLVE! JButton.
		solve.addActionListener(this);
		pi.addActionListener(this);
		e.addActionListener(this);
		img.addActionListener(this);

		// 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!