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

  • Home
  • SEARCH
  • 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 3322740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:13:08+00:00 2026-05-17T23:13:08+00:00

I have a JFrame with the JDesktopPane and inside the JDesktopPane, I launch with

  • 0

I have a JFrame with the JDesktopPane and inside the JDesktopPane, I launch with the constructor a JInternalFrame.
(Its a app like the authentification users, with the textbox user and textbox pass)

I lauch the internal like this:

MyInternalFrame internalF = new MyInternalFrame();
desktopPane.add(internalF);

I try with:

internalF.setVisible(true);
internalF.setSelected(true);
desktopPane.getDesktopManager().activateFrame(internal);
desktopPane.setSelectedFrame(internal);

How I can lauch the JInternalFrame and Its selected by default?
When I run the aplication, internalframe is like in background, Its not selected, Its not focused.

  • 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-17T23:13:09+00:00Added an answer on May 17, 2026 at 11:13 pm

    You can make the internal frame visible AFTER the desktop is created and the main frame is visible. In that case the frame will be selected by default.

    So, one example of what you can do:

    1. Create main frame
    2. Create desktop
    3. Create internal frame but don’t make it visible
    4. Start thread that sets visible to true on the internal frame, but the thread can wait until the desktop is shown
    5. Make the main frame visible
    6. In the thread call internalFrame.setVisible(true) and exit from the thread.

    In such case the internal frame will appear on the desktop and it will be selected as you want it.

    You might think of other solution without using threads, but writing handlers to the main frame’s events. In any case, to make the internal frame visible after it shows, you have to show it AFTER desktop with main frame is displayed.

    Here is the example, that you can use:

    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.HeadlessException;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    
    
    public class Main extends JFrame {
    
        private static final long serialVersionUID = 1L;
    
        private Internal internalFrame;
    
        public Main() throws HeadlessException {
            super("Internal Frame Test");
    
            setBounds(10, 10, 600, 400);
    
            setDefaultCloseOperation(EXIT_ON_CLOSE);
    
            this.setLayout(new BorderLayout());
    
            add(createDesktop(), BorderLayout.CENTER);
    
            addWindowListener(new WindowAdapter() {
                public void windowOpened(WindowEvent e) {
                    internalFrame.setVisible(true);
                }
            });
    
            setVisible(true);
        }
    
        private Component createDesktop() {
            JDesktopPane d = new JDesktopPane();
    
            internalFrame = new Internal("first");
            d.add(internalFrame);
    
            return d;
        }
    
        public static class Internal extends JInternalFrame {
    
            private static final long serialVersionUID = 1L;
    
            public Internal(String title) {
                super(title);
                setBounds(10, 10, 300, 100);
            }
        }
    
        public static void main(String[] a) {
            new Main();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of
I have a JFrame Gridlayout with components like buttons, JTextfields, JLabels. Sometimes when I
So I have a JFrame in which inside of it I have a JScrollPane
In my Java app, I have a JFrame window, how can I minimize it
I have a JFrame with a menu bar and a canvas covering all the
I have a JFrame that contains a display JPanel with JTextField and a control
I have a JFrame. This JFrame contains a JButton. I click the JButton and
My current problem is that I have a JFrame with a 2x2 GridLayout. And
This one's a tough one - I have a JFrame that generates JTextFields. When
Java Newbie here. I have a JFrame that I added to my netbeans project,

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.