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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:30:57+00:00 2026-06-12T19:30:57+00:00

I am creating a Swing Application. I have one main JFrame and a JDesktopPane

  • 0

I am creating a Swing Application. I have one main JFrame and a JDesktopPane. I added one button and one label on main frame. But if I open any JInternalFrame on Main Frame button and label covers the internal frame.

(JButtonand JLabel appear foreground of JInternalFrame). If I click internal frame button go to background.

Can you help to solve this?

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class MainFrame {

   JFrame frame1 ;
   JDesktopPane desktop ;

       public MainFrame () {
         frame1 = new JFrame("EMPLOYEE LEAVE TRACKER");
         frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame1.setExtendedState(Frame.MAXIMIZED_BOTH);
         frame1.repaint();
         desktop = new JDesktopPane();        //Creates a new JDesktopPane.
         frame1.setContentPane(desktop);
         frame1.setSize(900,700);
         frame1.setVisible(true);
         desktop.setBackground(Color.DARK_GRAY );

    //Creates a JLabel on JDesktopPane.
    JLabel label1 = new JLabel("EMPLOYEE LEAVE TRACKER", SwingConstants.CENTER);
       label1.setFont(new Font("SansSerif",Font.ITALIC + Font.BOLD,54));
       label1.setBounds(new Rectangle(new Point(275, 100),label1.getPreferredSize()));
    //Creates a JButon on JDesktopPane.


   JButton Leave = new JButton("Leave Management");
     Leave.setHorizontalTextPosition(JButton.CENTER);
     Leave.setBounds(new Rectangle(new Point(700,200),Leave.getPreferredSize()));
     Leave.setSize(300, 300);
     Leave.addActionListener(new java.awt.event.ActionListener()      {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e)   {
        frame1.add(LeaveManagment()); 
        }
    });

  //Look and Feel

     try {
        UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch(Exception e) {
          System.out.println("Error setting native LAF: " + e);
        }

    desktop.add(Leave);
    desktop.add(label1);

     }
   //Creating JInternalFrame

    public JInternalFrame LeaveManagment(){              
    final JInternalFrame employeeFrame = new JInternalFrame("LEAVE M" +
            "ANAGEMNT", true, true, true, true);
    employeeFrame.getContentPane().setBackground(Color.white);
    employeeFrame.setSize(900,700);
    employeeFrame.setVisible(true);
    employeeFrame.setMaximizable(true);
    employeeFrame.setResizable(true);
    JComponent c = (JComponent)
    employeeFrame.getContentPane();
    c.setLayout(new FlowLayout());

        return employeeFrame;
}

    public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      new MainFrame ();
      }
});
}}
  • 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-06-12T19:30:58+00:00Added an answer on June 12, 2026 at 7:30 pm

    From the sound of it, you’ve added the buttons to the JDesktopPane.

    The desktop pane is a type of JLayeredPane, this allows you to place components on, we’ll, layers.

    While this is a neat feature, IMHO, only JInternalFrames and the occasional special “window” should appear on the desktop (although the desktop manager does use a type of button to represent minimised windows)

    Personally, I’d place the buttons also where, not on the desktop.

    Take a look at How to Use Internal Frames and How to use Layered Pane

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

Sidebar

Related Questions

I am creating one GUI in swing Java. I have to use one button
Typically when I'm creating a Swing (or any UI) application, I have various Actions
I've creating a Java Swing application and I realized that I have many many
In my Swing application I have the problem that when creating a new instance
I'm creating a basic Swing applcation. I have jTextPane and a button. If the
I am creating an touch screen application using Swing and have a request to
I have a swing application which works fine as the desktop application but the
I am creating my java Swing application in Netbeans. At present there are more
I'm creating a Swing application to make a Game with. It creates images in
I am creating a Java Swing based desktop application in Netbeans. The application consists

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.