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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:30:37+00:00 2026-06-10T14:30:37+00:00

Status: I want to display 2 JPanels which contain images using a JSplitPane (one

  • 0

Status:
I want to display 2 JPanels which contain images using a JSplitPane (one image at the top, one image at the bottom)

When I move the divider of the pane, I want both panels to resize accordingly. (that the images take up the maximum possible space)

The Problem:
I’m using a PropertyChangeListener to track the change of position of the divider, but the event seems to be fired before the actual “repaint?” of the window has taken place

What i’ve tried:
– repainting the component before reading the size

Minimum working example:

public class Main {
public static void main(String argv[]) {
    MyFrame f = new MyFrame();
}
}

class MyFrame extends JFrame {
/**
 * 
 */
private static final long serialVersionUID = 1L;
JPanel anyPanel, anyPanel2;
JSplitPane p;

public MyFrame() {
    PropertyChangeListener resizeHandler = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            System.out.println(anyPanel.getHeight());
        }
    };

    anyPanel = new JPanel();
    anyPanel2 = new JPanel();
    p = new JSplitPane(JSplitPane.VERTICAL_SPLIT, anyPanel, anyPanel2);
    p.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, resizeHandler);
    getContentPane().add(p);
    this.add(p);
    this.pack();
    this.setVisible(true);
}
}
  • 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-10T14:30:39+00:00Added an answer on June 10, 2026 at 2:30 pm

    You need to add to the constructor

    p.setContinuousLayout(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a jprogressbar to indicate the availability status. i want to display
I want to update Paypal Order status and add tracking number using API. but
I've been stomping at this all day :( I want to display a status
I'm using DX_AUTH to handle autentication in my codeigniter app. I want to display
am doing chat app in which i want to display photo,adaptermodel,small icon for online
I want to display URL in a status bar. I want that status bar
I want to display an arrow which indicates the user to scroll up or
I want to display which all user is online (real time; like any chatting
I want to display a status message after a server side postback. Currently to
I am using following to fill my listview and don't want to display item

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.