StephNicolaou 32 Posting Whiz in Training

Update for anyone still willing to help:
I've stopped getting the error for the class now but still no moving circle. Heres what I did to get rid of my error. My MouseMove code looks just the same but instead I've added repaint() Please help!

public void paintComponent(Graphics g)
    {
        Graphics2D g2 = (Graphics2D) g;
        g.setColor (Color.red);
        playerCounter = new Ellipse2D.Double(30,30,30,30);
        setVisible(true);

       if (playerCounter != null){
            g2.draw(playerCounter);
        }
    }
StephNicolaou 32 Posting Whiz in Training

This is what I had for my class circle component excluding your if statement:

package mypackage;
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.Graphics;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.geom.Ellipse2D;

public class CircleComponent extends JComponent
{

    public CircleComponent() { }

    private Ellipse2D.Double playerCounter;
    private int xpos1 = 10;
    private int ypos2 = 10;
    private int width = 10;
    private int height = 10;

    public CircleComponent(int w, int h, int x, int y)
    {
        width = w;
        height = h;
        xpos1 = x;
        ypos2 = y;
    }

    public void paintComponent(Graphics g)
    {
        g.setColor (Color.red);
        playerCounter = new Ellipse2D.Double(30,30,30,30);
        setVisible(true);

        if (playerCounter != null){
            playerCounter.draw(g);
        }

    }
}

now I get a connot find symbol error for the .draw part. I think that it because I used Ellipse?

StephNicolaou 32 Posting Whiz in Training

I'm trying to make a circle appear from a class I've developed to move following the x co-ordinate of the mouse. I've done that part correctly, it's just loading the class...Can anyone tell me why it isn't loading?

I do love to solve problems myself but I've been working on this for a long time and I think it might be a silly mistake, I'm new to Java so I would really appreciate the help.

class MouseMovedListener implements MouseMotionListener
{
    public void mouseMoved(MouseEvent e)
    {

         xposcounter = e.getX();

         for(int i = 0; i <= grid.length; i++)
         {
              //Get the left hand side position of the grid
              int leftxpos = pCenter.getWidth()/2 - ((GapConstant*(grid.length+6)+(grid.length*rw))/2) + rw*i + GapConstant*i;
              
              //Get the right hand side position of the grid
              int rightxpos = pCenter.getWidth()/2 + ((GapConstant*(grid.length+6)+(grid.length*rw))/2) +rw*i + GapConstant*i;

                    //Show the counter appearing above the columns the mouse is over
                    if(xposcounter > leftxpos && xposcounter < rightxpos)
                    {
                        //Load the circle
                         CircleComponent mycounter = new CircleComponent();
                         
                    }
         }
    }

If you need to see the class code just ask...Thanks in advance for anyone who helps!

StephNicolaou 32 Posting Whiz in Training

There isn't exactly anything wrong with my code, it's fine although the order isn't correct, I think, which makes my shapes appear behind the center panel. I'm not sure how to correct this as I've drawn my shapes under a paint method.

I've tried moving the paint method before and after the initialising method and repainted in either methods but it will then present only one or the other; the combos/txts, etc or the shapes.

So at the moment I've positioned the shape method after the initialising method and have not repainted in neither methods. The shapes will only appear if I resize the applet, why is that?

-Sorry about all of the comments and thanks to anyone that helps

import java.awt.*;
import java.awt.event.*;
import java.awt.Shape;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPanel;

public class cinemabooking extends JApplet implements ActionListener, MouseListener
{
    //Variables


    JComboBox cboSeats;
    JComboBox cboTimes;
    JComboBox cboAge;

    JLabel lblTitle;
    JLabel lblSeats;
    JLabel lblTimes;
    JLabel lblAge;
    JLabel lblNoPeople;
    JLabel lblTotalCost;

    JLabel lblCenter;
    JLabel lblEast;
    JLabel lblWest;

    JTextField txtNoPeople;
    JTextField txtTotalCost;

    //Rectangle properties
    int rx = 120; //x position
    int ry = 100; //y position
    int rh = 30; //height
    int rw = 50; //width

    int x;
    int y;

    JPanel mainNorthPanel;
    JPanel eastPanel;
    JPanel southPanel;
    JPanel westPanel;
    JPanel centerPanel;
    JPanel row1;
    JPanel row2;

    public void init()
    {

        setSize(900,600);

        //Initialise Panels
               this.setLayout (new BorderLayout());

        //Initialise Combo Boxes

        //Seats Combo Boxes
        cboSeats = new JComboBox();
        String[] seatStrings = {"Left …