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 6610159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:48:16+00:00 2026-05-25T19:48:16+00:00

So, in my last question (Can’t figure out how to overlap images in java)

  • 0

So, in my last question (“Can’t figure out how to overlap images in java”) I was kindly advised to utilize layout managers and the JLayeredPane. However, after studying the demos, and forming my own code, I have a whopping 34 compiler errors. The compiler errors are consistently “” so there’s probably something wrong with importing. However I copied the import list exactly from the LayeredPane Demo. Once again, I am stumped. And also once again, I thank anyone in advance for advice!

import javax.swing.*;
import javax.swing.border.*;
import javax.accessibility.*;

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


public class SlotAnimatorTest extends JPanel
{
  JPanel pane = new JPanel ();
  pane.setPreferredSize(new Dimension(1500, 1500));
  JPanel slotAnim;

  private JPanel showSlotAnimators ()
  {
    slotAnim = new JPanel ();

    SlotAnimator a0 = new SlotAnimator (45);
    SlotAnimator a1 = new SlotAnimator (90);
    SlotAnimator a2 = new SlotAnimator (180);

    slotAnim.setLayout (new GridLayout (3,0,20,30));
    slotAnim.add (a0);
    slotAnim.add (a1);
    slotAnim.add (a2);

    return slotAnim;
  }

  ImageIcon background = new ImageIcon ("/Users/haleywight/Documents/slotmachine.png");
  JLabel bG = new JLabel (background);
  bGsetBounds(1500, 760, background.getIconWidth(), background.getIconHeight());
  pane.add (bG, newInteger(0),0);

  pane.add (showSlotAnimators (), newInteger (1));

      private static void createAndShowGUI() 
      {

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JComponent newContentPane = new SlotAnimatorTest();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
     }

  public static void main (String [] args)
    {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }

}
  • 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-25T19:48:16+00:00Added an answer on May 25, 2026 at 7:48 pm

    This has nothing to do with JLayeredPane and much to do with basic Java. You can’t call a method in the class and outside of a method or constructor or static/non-static initializer blocks.

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

Sidebar

Related Questions

Let me rephrase my last question, what PHP library or framework can I use
I managed to sort out the calculation but there is just one last question
Following up from my last question does anyone know how I can use a
Further to my last question , I'd like to know if current browsers can
In my last question I asked about parsing the links out of an HTML
A lot of people where confused by my last question. I hope I can
Hopefully my last question for a little while, although I can't be sure... I'm
Can any one help me with this problem? As in my last question, I
Continuing from my last question , I'd like to know how can I bind
I want to show the user last activity. (you can read my last question

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.