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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:03:35+00:00 2026-06-04T12:03:35+00:00

I tried to access a JInternalFrame in my JDesktopPane and use getAllFrames method. I

  • 0

I tried to access a JInternalFrame in my JDesktopPane and use getAllFrames method.

I just want to access the JInternalFrame in the order that i added into the JDesktopPane.
for example, i add a,b,c

frames[0] contain a
frames[1] contain b
frames[2] contain c 

But i found out that the content in the array will change in case that i change my selection.
Every time I change my selection.
The selected JInternalFrame in the array will move to the top one.

For example , I select b
The array will become

frames[0] contain b
frames[1] contain a
frames[2] contain c 

Are there any other ways to get the internal frame in the order i add it into desktoppane??

  • 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-04T12:03:36+00:00Added an answer on June 4, 2026 at 12:03 pm
        package org.app;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.event.InternalFrameAdapter;
    import javax.swing.event.InternalFrameEvent;
    
    
    public class MainFrame extends JFrame{
        private static final long serialVersionUID = 1L;    
        private JDesktopPane theDesktop;
        private List<JInternalFrame> frameList=new ArrayList<>();
    
    public MainFrame()  {
        super("Internal Frame Demo");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(800,600);
        this.setJMenuBar(setMenubar());
        theDesktop=new JDesktopPane();
        this.add(theDesktop);
        this.setVisible(true);
    }
    
    public JMenuBar setMenubar()    {
        JMenuBar bar=new JMenuBar();
        JMenu addMenu=new JMenu("Add");
        JMenuItem newFrame=new JMenuItem("Internal Frame");
        newFrame.addActionListener(new MenuAction());
        addMenu.add(newFrame);
        bar.add(addMenu);
        return bar;
    }
    
    public JInternalFrame addInternalFrame()    {
        JInternalFrame jif=new JInternalFrame("Internal frame",true,true,true,true);
        jif.setSize(new Dimension(240, 300));       
        jif.addInternalFrameListener(new InternalFrameAdapter() {
            @Override
            public void internalFrameClosing(InternalFrameEvent e){             
                frameList.remove(e.getInternalFrame());                 
                System.out.println("from frame closing event");         
            }
        });
        jif.show();
        return jif;
    }   
    public JInternalFrame getInternalFrame(int index)   {
        return frameList.get(index);
    }   
    class MenuAction implements ActionListener  {
        @Override
        public void actionPerformed(ActionEvent e) {            
            JInternalFrame f=addInternalFrame();
            theDesktop.add(f);
            frameList.add(f);           
            System.out.println("from menu action");
        }           
    }   
    public static void main(String[] args){
        new MainFrame();
    }
    

    }

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

Sidebar

Related Questions

I've tried to access buttons in my menu. I only want to add listeners
I tried some add to favorties JavaScript scripts.. With IE8, I get an access
I am trying to access a page method from centralized module. I tried putting
I want that when a non logged in user tries to access any controller
I just tried to access my superblock information using the code as shown here:-
I have tried to access a website that i created in my xp machine
I have just uploaded a new website www.tapasya.co.in . When I tried to access,
I'm using Spring 3 and I tried to access url that has no mapping
I tried many different things to access a google Account in order to read
I tried to access my Gmail mailbox with InterImap Library. It shows my messages

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.