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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:29:35+00:00 2026-05-24T18:29:35+00:00

I have a simple extended JSplitPane that I set different panels to at different

  • 0

I have a simple extended JSplitPane that I set different panels to at different times when they are needed. Specifically, I split it into an upper and lower section, and I swap out the bottom section frequently. Each time I do, I reset the slider position to how I want it, but sometimes it jumps off at and re-positions itself to the top of the screen (not always).

Here’s my code:

public class MainPanel extends JSplitPane{

    public Screen screen;

    public int height;

    public ControlPanel curPanel;

    public MainPanel(Screen screen, int height){
        super(JSplitPane.VERTICAL_SPLIT);

        this.screen = screen;
        this.height = height;

        setDividerSize(2);
        setEnabled(false);

        setTopComponent(screen);

        setToInitControls();
    }

    public void setToInitControls(){
        InitControls initCtrls = new InitControls(this);
        setBottomComponent(initCtrls);
        curPanel = initCtrls;
        setDividerLocation(height / 4 * 3);
    }

    public void setToConfigControls(){
        ConfigControls configCtrls = new ConfigControls(this);
        setBottomComponent(configCtrls);
        curPanel = configCtrls;
        setDividerLocation(height / 4 * 3);
    }

    public void setToWaitControls(){
        WaitControls waitCtrls = new WaitControls(this);
        setBottomComponent(null);
        setBottomComponent(waitCtrls);
        curPanel = waitCtrls;
        setDividerLocation(height / 4 * 3);
    }

    //and so on (I have more methods like these further down)

    //OVERRIDES: I figured overriding these might help. It didn't.
    @Override
    public int getMinimumDividerLocation(){
        return (height / 4 * 3);
    }
    @Override
    public int getMaximumDividerLocation(){
        return (height / 4 * 3);
    }
}

Basically, I use the “setTo…Controls()” methods to swap bottom panels. Is there a way to tell the slider to stay put where I placed it regardless of the panel’s preferred sizes, or if not, how do I make the panels know what to shape themselves to fit in? Thanks for any/all suggestions!

EDIT: I should note that these panels do not use layouts. They are custom panels that I use mouse/keyboard listeners on and use my own graphics to paint over them.

  • 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-24T18:29:36+00:00Added an answer on May 24, 2026 at 6:29 pm

    I found the solution, thanks to the links above. It’s actually quite simple. Instead of using

    setDividerLocation(height / 4 * 3);
    

    for every time I added a component, I just replaced it with:

    setResizeWeight(0.66);
    

    Did that once inside the constructor, and it never bothered me again. 0.66 is the equivalent decimal position to h/4*3 (I just trial-and-errored it).

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

Sidebar

Related Questions

I have a simple extender component that draws 3D borders around any Control. In
I have simple win service, that executes few tasks periodically. How should I pass
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package where I import data from flat file into SQL
I am trying to create a simple 3-D app for android that will have
I have an application that is currently divided into Service and Data Access Layers
I have a member profiles application that stores simple information about members of a
I have an existing .NET 3.5 based framework that is extended using custom plugins.
I want to have an ASP C# WebSite that loads a simple CSV File
I have a simple control that has a masked text box: xmlns:extToolkit=http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended ... <extToolkit:MaskedTextBox

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.