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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:04:43+00:00 2026-05-24T06:04:43+00:00

I need the iconable/minimize feature of JInternalFrame to collapse the frame (which it does),

  • 0

I need the iconable/minimize feature of JInternalFrame to collapse the frame (which it does), but also maintain the JInternalFrame’s position within its parent component. Currently, when I press the minimize button of a JInternalFrame, java places the component at the bottom of its container. Is there a way to maintain the location whilst minimizing? If there is no obvious solution, how might I observe the iconable icon and remove the default listener? Thank you.

  • 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-24T06:04:44+00:00Added an answer on May 24, 2026 at 6:04 am

    To modify this behavior you would want to create an implementation of javax.swing.DesktopManager. To get the majority of the default behavior already available I’d suggest subclassing javax.swing.DefaultDesktopManager.

    In DefaultDesktopManager the method iconifyFrame(JInternalFrame f) controls the complete behavior but internally uses the method protected Rectangle getBoundsForIconOf(JInternalFrame f) to determine the bounds for the icon of the frame being minimized. Here you can return the bounds for the icon of the internal frame that you’d like to use. The problem is those values are cached so if you want it to move every time you would need to do something like the following.

    import javax.swing.DefaultDesktopManager;
    import javax.swing.DesktopManager;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.SwingUtilities;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    
    public class CustomDesktopManager extends DefaultDesktopManager {
        @Override
        public void iconifyFrame(JInternalFrame f) {
            super.iconifyFrame(f);
    
            JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
            Dimension prefSize = icon.getPreferredSize();
            icon.setBounds(f.getX(), f.getY(), prefSize.width, prefSize.height);
        }
    
        public static void main(String args[]) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
                    JDesktopPane desktopPane = new JDesktopPane();
                    DesktopManager dm = new CustomDesktopManager();
                    desktopPane.setDesktopManager(dm);
                    JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
                    internalFrame.setSize(200, 150);
                    internalFrame.setVisible(true);
                    desktopPane.add(internalFrame);
    
                    frame.add(desktopPane, BorderLayout.CENTER);
                    frame.setSize(800, 600);
                    frame.setVisible(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help getting the list within the wrapper div. Also the images that I
Need a way for one service on a well-known Endpoint to return strings which
Need some help please with this error : TypeError : 'unicode' object does not
need a simply preg_match, which will find c.aspx (without quotes) in the content if
Need to launch a new ASP.NET site on this server but need to be
Need your suggestion on php/mysql software. I develop PHP websites using Dreamweaver, I also
Need prettier solution of below example but with std::accumulate. #include <algorithm> #include <vector> #include
need help here, been fixing for hours but to no avail. i will like
Need to disable log4j output to console during jUnit tests running but all other
Need to convert byte arrays of images and videos back to its origin. I

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.