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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:10:13+00:00 2026-05-15T15:10:13+00:00

I have a java application for an ATC. I just got started with the

  • 0

I have a java application for an ATC. I just got started with the GUI. First I have a Mainframe, a JLayeredPane on this mainframe, and panels with labels(having ImageIcons) inside them on the JLayeredPane.

I have successfully added about 4 panels(panels have labels,and labels have ImageIcons) to the JLayeredPane. When I go to add the fifth panel, it gives me a wrong GUI display.

This what I get before adding pnlplane(4 layers):

This is what I get(when I try to add a pnlplane – 5 layers[problem]):

This is what I should have got:

import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

public class GUI extends JFrame {

JFrame main = new JFrame();

JLayeredPane jp = new JLayeredPane();

//Add JPanels here
JPanel pnlbackground = new JPanel();
JPanel pnlrunwayone = new JPanel();
JPanel pnlrunwaytwo = new JPanel();
JPanel pnlholding = new JPanel();
JPanel pnlplane = new JPanel();




//Add ImageIcons here
ImageIcon imgbackground = new ImageIcon("background.gif");
ImageIcon imgrunwayone = new ImageIcon("runway01.gif");
ImageIcon imgrunwaytwo = new ImageIcon("runway01.gif");
ImageIcon imgholding = new ImageIcon("holding01.gif");
ImageIcon imgplane = new ImageIcon("plane.gif");




//Add JLabels here
JLabel lblbackground = new JLabel(imgbackground);
JLabel lblrunwayone = new JLabel(imgrunwayone);
JLabel lblrunwaytwo = new JLabel(imgrunwaytwo);
JLabel lblholding = new JLabel(imgholding);
JLabel lblplane = new JLabel(imgplane);




public GUI() {

    //Background
    pnlbackground.setOpaque(false);
    pnlbackground.setBounds(0, -5, 1024, 768);
    pnlbackground.add(lblbackground);

    //Runway one
    pnlrunwayone.setOpaque(false);
    pnlrunwayone.setBounds(170, 404, 685, 39);
    pnlrunwayone.add(lblrunwayone);

    //Runway two
    pnlrunwaytwo.setOpaque(false);
    pnlrunwaytwo.setBounds(170, 443, 685, 39);
    pnlrunwaytwo.add(lblrunwaytwo);

    //        Holding pattern
    pnlholding.setOpaque(false);
    pnlholding.setBounds(0, 00, 330, 143);
    pnlholding.add(lblholding);

    //plane
    pnlholding.setOpaque(false);
    pnlholding.setBounds(0, 0, 48, 60);
    pnlholding.add(lblplane);


    //Adding them to each other
    add(jp);
    jp.add(pnlbackground, new Integer(0));
    jp.add(pnlrunwayone, new Integer(1));
    jp.add(pnlrunwaytwo, new Integer(2));
    jp.add(pnlholding, new Integer(3));
    jp.add(pnlplane, new Integer(4));




    //MainFrame properties
    setSize(1024, 768);
    setBackground(Color.BLACK);
    setTitle("Air Traffic Control");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);


}

public static void main(String[] args) {

    new GUI();

}
}

The easier way out is to go and put all the images together to one big image in photoshop. However, I would like to know if there is any other fix available out there.

  • 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-15T15:10:13+00:00Added an answer on May 15, 2026 at 3:10 pm

    Your code seems to work fine for me. That is I see 5 images.

    This looks a little strange:

    pnlholding.setOpaque(false); 
    pnlholding.setBounds(0, 00, 330, 143); 
    pnlholding.add(lblholding); 
    
    //plane 
    pnlholding.setOpaque(false); 
    pnlholding.setBounds(0, 0, 48, 60); 
    pnlholding.add(lblplane); 
    

    I think the lblplane should be added to pnlplane.

    Even easier is to just add the label to the layered pane directly, there is no need to add it to a panel first. This is the way the Swing tutorial on How to Use Layered Panes works.

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

Sidebar

Ask A Question

Stats

  • Questions 457k
  • Answers 457k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You place them either on the field or on the… May 15, 2026 at 10:43 pm
  • Editorial Team
    Editorial Team added an answer Unregister doesn't work because you're using an anonymous method (lambda… May 15, 2026 at 10:43 pm
  • Editorial Team
    Editorial Team added an answer Try DBSourceTools. http://dbsourcetools.codeplex.com Its open source, and specifically designed to… May 15, 2026 at 10:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.