Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:02:07+00:00 2026-05-31T01:02:07+00:00

Game.java calls a function getLabel() present in board.java. When I am running Game.java, I

  • 0

Game.java calls a function getLabel() present in board.java. When I am running Game.java, I am getting error “cannot find symbol method getLabel()” in the terminal. I am not able to correct it.

Game.java

import java.awt.*;
import javax.swing.*;
import javax.swing.JLabel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class Game {

    private board b;
    private bishop bis1;
    private JLabel q;

    public static void main(String[] args) {
        Game f = new Game();
        f.start();
    }

    public void start() {
        b = new board();
        bis1 = new bishop();
        bis1.setLocation(0, 0);
        ImageIcon m = bis1.getImage();
        q = b.getLabel();

        q.addMouseListener(new Mouselist());
        b.squares[0][0].add(q);
    }

    class Mouselist implements MouseListener {

        public void mouseClicked(MouseEvent e) {
            //k.setIcon(null);
            b.squares[1][1].add(new JLabel(new ImageIcon("rook.png")));
        }

        // mouse entered the JLabel increment count and display it
        public void mouseEntered(MouseEvent e) {
            b.squares[1][1].add(new JLabel(new ImageIcon("rook.png")));
        }

        public void mouseExited(MouseEvent e) {
            b.squares[1][2].add(new JLabel(new ImageIcon("rook.png")));
        }

        // mouse was presssed (cliked and released)
        // increment counter and display it
        public void mousePressed(MouseEvent e) {
            b.squares[1][1].add(new JLabel(new ImageIcon("rook.png")));

        }

        public void mouseReleased(MouseEvent e) {
            b.squares[1][1].add(new JLabel(new ImageIcon("rook.png")));
        }
    }
}

board.java

import javax.swing.*;
import java.awt.*;
import javax.swing.JLabel;

public class board {

    public JFrame frame;
    public JPanel squares[][] = new JPanel[3][3];
    private JLabel sqk = new JLabel(new ImageIcon("knight.png"));

    public board() {
        frame = new JFrame("Simplified Chess");
        frame.setSize(1200, 800);
        frame.setLayout(new GridLayout(2, 3));

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                squares[i][j] = new JPanel();

                if ((i + j) % 2 == 0) {
                    squares[i][j].setBackground(Color.black);
                } else {
                    squares[i][j].setBackground(Color.white);
                }
                frame.add(squares[i][j]);
            }
        }

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public JLabel getLabel() {
        return sqk;
    }
}

What is possibly wrong here ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:02:08+00:00Added an answer on May 31, 2026 at 1:02 am

    Most probably you have just added the getLabel() method and haven’t yet recompiled board.java

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating simple chess board game in java, and they are running smoothly,
I'm using the java swing library to develop a board game called DAO. The
I was trying to make a board game in java and i am stuck
For my Java game server I send the Action ID of the packet which
I'm writing a game in Java, and I want the user to be able
I'm writing a Java game and I want to implement a power meter for
I am making a game in JAVA where I want to come up with
Can anyone recommend a good Java game engine for developing simple tile-based games? I'm
I am writing a game in Java, and need to have mouse interaction. I
I am writing a simple checkers game in Java. When I mouse over the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.