JSplitPane keeps right-hand component same size

I have a JInternalFrame... on its content pane sits a JScrollPane. Viewport view of JScrollPane is set to a JSplitPane.
I want to make it so that, when the split pane divider is pulled either way (left or right), the right-hand component stays the same size... i.e. the width of the JSplitPane grows or diminishes accordingly. Obviously you would then see this reflected in the width and position of the slider of the horizontal scroll bar of the JScrollPane.
I'm finding this very difficult to implement. To the point that I'm wondering whether I have to subclass BasicSplitPaneUI.BasicHorizontalLayoutManager ... which itself is not clear because the ** horizontal ** layout manager can't be instantiated (although its subclass the ** vertical ** layout manager can be).
Alternatively I'm wondering if maybe JSplitPane is just not designed for such a purpose... in which case which layout manager would be appropriate? I'm not an expert on them... but do any of them actually give you a bar of some kind by which to resize one of their components? This is the attraction of JSplitPane for me...
Another possibility might I suppose be a 1 row x 2 col JTable... but I'd like to find a split pane solution ideally

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JSplitPane;
public class SimpleJSplitPaneTest {
     public static void main(String[] a_args) {
          EventQueue.invokeLater(new Runnable() {
               public void run() {
                    new SimpleJSplitPaneTest();
     SimpleJSplitPaneTest() {
          final JFrame f_mainFrame = new JFrame( "Simple JSplitPane test");
          f_mainFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
          f_mainFrame.setSize(800, 400);
          JDesktopPane desktopPane = new JDesktopPane();
          f_mainFrame.getContentPane().add(desktopPane, BorderLayout.CENTER );
          desktopPane.setBackground( Color.blue );
          final JInternalFrame f_internalFrame = new JInternalFrame("New JInternalFrame", true, true, true, true );
          f_internalFrame.setResizable(true);
          f_internalFrame.setBounds(0, 0, 450, 250 );
          desktopPane.add(f_internalFrame);
          JScrollPane mainScrollPane = new JScrollPane();
          f_internalFrame.getContentPane().add(mainScrollPane, BorderLayout.CENTER );
          // rh panel of main split pane
          final JPanel f_rHPanel = new JPanel();
          // main split pane
          final JSplitPane f_mainSplitPane = new JSplitPane(){
               public boolean isValidateRoot(){
                    boolean result = super.isValidateRoot();
                    p( "== isValidateRoot - result: " + result );
                    return result;
               public void resetToPreferredSizes(){
                    p( "== resetToPreferredSizes" );
                    super.resetToPreferredSizes();
               public void doLayout(){
                    int lastDivLoc = this.getLastDividerLocation();
                    int presDivLoc = this.getDividerLocation();
                    int diff = presDivLoc - lastDivLoc;
                    p( "== diff " + diff );
                    if( diff != -1 ){
                         Dimension mainPrefSize = this.getPreferredSize();
                         Dimension mainSize = this.getSize();
//                         this.setPreferredSize( new Dimension( mainPrefSize.width + diff, mainPrefSize.height ));
// THIS DOESN'T WORK:
//                         this.setSize( new Dimension( mainSize.width + diff, mainSize.height ));
                         Dimension rHPrefSize = f_rHPanel.getPreferredSize();
                         Dimension rHSize = f_rHPanel.getSize();
//                         f_rHPanel.setPreferredSize( new Dimension( rHPrefSize.width + diff, rHPrefSize.height ));
// THIS DOESN'T WORK:
//  Whoops! Of course it's the LEFT panel which needs to have its "pref size" or "size" altered after a divider
// movement... but that doesn't work either... thing is, I have been experimenting with code quite a bit... best thing
// is to ignore this "remnant" code ...
//                         f_rHPanel.setSize( new Dimension( rHSize.width + diff, rHSize.height ));
                    p( "== doLayout" );
                    super.doLayout();
               public void validate(){
                    p( "== validate" );
                    super.validate();
          mainScrollPane.setViewportView(f_mainSplitPane);
          // lh panel of main split pane
          final JPanel f_lHPanel = new JPanel();
          f_lHPanel.setBackground( Color.red );
          f_mainSplitPane.setLeftComponent(f_lHPanel);
          f_lHPanel.setPreferredSize( new Dimension( 300, 200 ));
          f_lHPanel.setSize( new Dimension( 300, 200 ));
          f_mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
               @Override
               public void propertyChange(PropertyChangeEvent pce) {
                    System.out.println( "PROP CHANGE: main div changed");
                    int lastDivLoc = f_mainSplitPane.getLastDividerLocation();
                    int presDivLoc = f_mainSplitPane.getDividerLocation();
                    int diff = presDivLoc - lastDivLoc;
// NOTHING HERE SEEMED TO WORK
                    printSizes( "  f_lHPanel", f_lHPanel );
                    printSizes( "  f_rHPanel", f_rHPanel );
                    printSizes( "  f_mainSplitPane", f_mainSplitPane );
          f_rHPanel.addComponentListener( new ComponentAdapter(){
          public void componentResized(ComponentEvent e){
               System.out.println( "RHPanel resized" );
               int lastDivLoc = f_mainSplitPane.getLastDividerLocation();
               int presDivLoc = f_mainSplitPane.getDividerLocation();
               int diff = presDivLoc - lastDivLoc;
               p( "  diff: " + diff );
               Dimension mainPrefSize = f_mainSplitPane.getPreferredSize();
               Dimension mainSize = f_mainSplitPane.getSize();
//               f_mainSplitPane.setPreferredSize( new Dimension( mainPrefSize.width + diff, mainPrefSize.height ));
// THIS DOESN'T WORK:
//               f_mainSplitPane.setSize( new Dimension( mainSize.width + diff, mainSize.height ));
               printSizes( "  f_lHPanel", f_lHPanel );
               printSizes( "  f_rHPanel", f_rHPanel );
               printSizes( "  f_mainSplitPane", f_mainSplitPane );
          f_mainSplitPane.setRightComponent(f_rHPanel);
          f_rHPanel.setPreferredSize( new Dimension( 500, 200 ));
          f_rHPanel.setSize( new Dimension( 500, 200 ));
          f_internalFrame.setVisible(true);
          f_mainFrame.setVisible(true);
     public static void printSizes( String name, Component comp ){
          System.out.println( name + ": size: " + comp.getSize() + "; pref size: " + comp.getPreferredSize() );
     private static void p(String s) {
          System.out.println(s);
}as the main JSplitPane's divider is dragged right or left, I have found no way of keeping the main JSplitPane's RH component (JPanel) the same size... the problem is that if you, for example, find out the pixel change of the divider, and alter the size of main JSplitPane accordingly, it appears that a "do layout" event is called...
I've tried quite a few permutations and various listeners... either I get an endless loop of events calling events, or the divider simply snaps back to where it was... or the "printSizes" print-outs show that things are not the sizes they appear (which of course simply means that a subsequent event occurs which changes the sizes)...
And, as I said, I don't know how to subclass BasicSplitPaneUI.BasicHorizontalLayoutManager

Similar Messages

  • How do I keep my selections the same size when placing in another picture?

    Using PSE 4, I am trying to take my head from one picture (Using the selection tool, etc) and place it in another. The problem is, whenever I try to do that, it changes sizes; gets smaller. Yesterday, I tried to take a part of larger picture and place it into a smaller picture. I tried to resize the background picture but it made the cutout I placed on top of it humungous. I just want to know, is there anyway to keep the actual size of something you cut out, and place in another picture, that same size no matter what? By the way, I have literally been using PSE 4 for 3 days. If you answer, please speak in layman's terms as much as possible. Thank You.

    The size, in pixels, is staying the same. Most of the time, this is the way you should think of image size. Working in inches is only meaningful when you are about to print.
    In your example, if the piece you have added is too small, select it and use Transform to make it bigger. This is upsampling, so quality may be compromised.

  • How do I keep a table the same size but change the width of columns?

    I know this is probably a really stupid question. But after looking online and at the table palette... I still can't figure it out! In Quark, I can "maintain the geometry" of a table by clicking a box. That way, I can change the width or height of rows and columns... without changing the overall size of the table itself. How do I lock down the overall size of a table in InDesign? Thanks...
    Julie

    @Julie – you can change column width by alt + shift + dragging left or right cell sides without changing the overall size of the table.
    For other table goodies see:
    http://indesignsecrets.com/18-handy-table-shortcuts.php
    Hope that helps!
    Uwe

  • Keep front panel icons same size on different monitors

    I was wondreing if there was anyway where you can make your front panel automatically adjust itself to fit the full size screen of other computers with different resolutions than the one that the front panel was developed on.
    thank you

    Try this thread.
    http://forums.ni.com/ni/board/message?board.id=170​&thread.id=291198&view=by_date_ascending&page=1
    I have concluded nothing works and if any of my programs will be used on different monitors I will develope the program in the lowest resolution needed.

  • ITunes keep repeating a song in my playlist.  The repeat icon is no longer on the upper right hand side

    iTunes keep repeating a song in my playlist on my iphone (4 I thnk).  The repeat icon is no longer on the upper right hand sideiTunes keep repeating a song in my playlist.  The repeat icon is no longer on the upper right hand side

    I looked under file but I couldn't find the "Genius & Playlist" option. I also looked under the other options on the top left side but I couldn't find it there either. And all "Genius suggestions" does for me is show similar songs already purchased in my library. It doesn't show me anything new that I haven't purchased.

  • How do I change the size of my screen, in Develop Module, so that I can access the Exposure Slide in the right-hand colummn?

    The right-hand column, under the Develop Module, begins with the Histogram and directly under the Histogram, the Tone Curve is seen.  Missing is the Exposure Slide.  How do I change the size of the screen to show the Exposure Slide before the Tone Curve?

    Right-click (Cmd-click Mac) on the tone curve panel header or any of the other panel headers and make sure there is a checkmark for Basic.

  • Looking for a crop that will allow me to keep all the heads the same size

    looking for a crop that will allow me to keep all the heads the same size. Iam a School photographer and have been looking for a crop tool mask out liner ect that will alow me to crop and see that head sizes remain the same throught out a job can any one help with this question?

    I *think* I'm understanding that Eisenray is asking. Similar to the crop overlays, like Grid or Spiral, he would like one with an oval, to help hi better size the heads in the photos. I believe in each photo, the heads have to be the same size.
    What he *could* do, is create a rectangle with an oval punched out of it. He could drag the image to an 8x10 300ppi document, and that rectangle can be overlayed on his photo, then he can shrink/enlarge the photo to fit the oval...if that makes sense.
    It's difficult to understand, do if I'm wrong, please let us know, Eisenray.

  • How can I enlarge my tabs and keep them the way I set them? My page zooms in and out but my file, bookmarks, etc. tabs stay the same size.

    using the view tab, I select Zoom. Zoom in only increases appearance of web page. The tabs (File, Edit, View, History, Bookmarks, Tools and Help) all remain the same size! Way too small to read! This sucks and I don't LIKE IT!

    That sounds very handy. Nice going. A kind of backup would be to
    create a folder in the Bookmarks Manager, and keep a list of links there.
    Just one note. The sessionstore file shows the last windows / tabs that
    are open. Because the window with the 90 tabs was closed first, then the
    other, that is what caused your issue.
    Please edit the post title by adding '''==Solved==''' to it. Others may think
    you are asking for help, not offering a solution.

  • 4500 envy cuts off right hand side of pdf document when I print to letter size paper

    This is a new printer for me.  It is connected to my laptop with a USB cord.  I am attempting to print an e-mailed PDF document .  When I preview, I see that the right-hand side of the document is cut off  by more than an inch.  How do I get the printer to format the document to fit on letter-sized paper? Reducing the document size to under 100 % does not help.

    Thank you for your response!  Try the steps below in order, and try printing your email again. Let me know what happens! Reset the printing systemRepair disk permissionsRestart the MacClick here to download and install the printers Full Driver: HP ENVY 4500 e-All-in-One PrinterTry printing your email and also from Text Edit. Good luck! 

  • Top right hand of task bar icons keep disappearing and coming back. I cannot click on any of them as they just go. Also I cannot take screenshots any more. Macbook pro 2007 OSX Snow Leopard

    Top right hand of task bar icons keep disappearing and coming back. I cannot click on any of them as they just go. Also I cannot take screenshots any more. Macbook pro 2007 OSX Snow Leopard. Anybody any idea what is occurring?

    These Steps should resolve your issue
    Step by Step to fix your Mac
    If you don't have a backup of your data off the machine
    Most commonly used backup methods
    If you can't boot the machine and need to get data off it
    Create a data recovery/undelete external boot drive
    Your options for data recovery
    My computer is dead, is my personal data lost?
    Secure data removal
    How do I securely delete data from the machine?
    More:
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents#/

  • I have iMovie application open, but the iMovie application keeps disappearing off the right hand side of the screen and and I can not see it, even though the application is open..help, please!

    I have iMovie application open, but the iMovie application keeps disappearing off the right hand side of the screen and and I can not see it, even though the application is open..help, please!

    Thanks. I don't know why it wouldn't just go back there when I tried putting it back? I didn't change anything, so I assumed the new "default" was over on the left. Glad it was a simple solution after all.

  • When I open an email, my computer won't go to the link listed, or when I am doing research the same thing, then I see a ALLOW in the upper right hand corner of the screen and I have to click on that. What happened and how do I fix this?

    Somehow my settings have changed. When I open an email and there is a link, my computer won't allow it, also when I am doing a search, my computer won't allow certain links to open.
    What I see is "ALLOW" in the upper right hand corner of the screen, and I have to click on that in order to continue my email or do a search. How did this suddenly happen and how do I change it back to being able to roam the Internet without having to click on ALLOW all the time?
    Also, I set up Google as my home page, but it won't list Email or any other options. I have to type in Google in the Google box, then Email appears. How do I get the right Google set up as my home page so I can access Email without jumping through hoops.
    Thanking you so much for your time and consideration.
    Sincerely,
    [email protected]

    Sign out of the iTunes Store. Sign in again.
    tt2

  • Why all of a sudden has one of my apps (Condition Report App) only displaying at the top right hand corner it is a quarter of the size it should be, i have tried setting my ipad back to factory settings and this hasnt helped some please help??? :)

    One of my apps (condition report app) has decided to only display on the top right hand corner which is only a quarter of the screen, not sure what has happened as i have not changed any settings went to go into it one day and it was just like it.
    Please help!!!! Thanks Kristy

    Do you have the most up-to-date version of the app? Did you upgrade to iOS 6? Did you check to make sure that the developer has updated the app for the new OS? Have you tried resetting your device by pressing and holding the Home button and power button until the silver apple appears? Have you tried uninstalling and re-installing the app?

  • PDF output characters right hand side getting truncated using --PASTA

    H All,
    DB:11.1.0.7
    Oracle Apps:12.1.1
    O/S:Linux Red Hat 86x64
    We are getting right hand side characters truncated for PDF output when Conc Prog is run through EBS.This is the problem.
    But while saving the file on dektop and printing both left and right hand side characters gets printed well within the margin area.
    What could be the problem here please?Could anyone please share the resolution.
    Page size used is: 81/2 x 11 - Letter.
    Thanks for your time!

    We are getting right hand side characters truncated for PDF output when Conc Prog is run through EBS.This is the problem.Is it a seeded or custom concurrent program? Does this happen to all requests or specific ones only?
    But while saving the file on dektop and printing both left and right hand side characters gets printed well within the margin area.What if you print the same file from the server using the lp command?
    What could be the problem here please?Could anyone please share the resolution.
    Page size used is: 81/2 x 11 - Letter.What is the printer type/style?
    Have you tried different printer?
    Also, have you tried to adjust the number of Rows/Columns of this concurrent program?
    Please see if (Custom Landscape Reports In PDF Format Print In Portrait Orientation [ID 421358.1]) helps.
    Thanks,
    Hussein

  • How do I get rid of that annoying right-hand column in Reader 11.0.3?

    It just won't go away!  I can't find anything on the menus to get rid of it.  It blocks the view of whichever document I'm trying to read.  What's odd is that when I first opened a PDF document, it looked just fine; but subsequent openings of the same document had that right-hand column blocking about one-fourth of the document, requiring horizontal scrolling.  Who can be bothered?  Please tell me this is an easy fix.  Thank you!

    Half of a solution has been offered for this problem: Click on Tools, then click on Tools again. This is so un-obvious that I have to guess it removes the column as a fluke of what's been clicked, not because that is the defined way to remove the column. And the screen shot helped those who haven't seen it. But I've been reading the Freakonomics guys and I have to say that the right question was not asked. Here's the right question:
    How can I keep that stupid worthless column from EVER showing up again? I mean, it's nice to have instructions on how to change a tire, but it's even nicer to have a car that doesn't have a blowout every time I try to go for a drive!
    I have searched Preferences and cannot find anything that seems to relate to it.
    Thanks for your attention to this issue.

Maybe you are looking for

  • [solved] can't ssh AWS EC2 anymore - iptables flushed

    Hi, I killed a AWS's EC2 connexion by flushing iptables on server side, can't connect anymore. I connect to an Amazon's EC2 instance (with Ubuntu) mainly as a proxy, from a linux system based laptop, to go through an university's firewall. (For a hea

  • Ipad asking for password but dont have one

    I updated my ipad 2 last night to IOS7 and now its asking for a pasword but I dont have one so I cant even open the thing in order to reset one! Ive tried my iphone password but that doesnt work. Help

  • HT201304 i have forgotten my restrictions passcode can anyone help me??

    I locked my restrictions because my daughter that is 3 likes to delete my apps well i locked them using a passcode and have 27 failed attempts and obviously can not remember it can anyone help me please!!!!!!! i have restored it and still cant unlock

  • How to Use LABVIEW charts with Mathscript

    Hi,    I recently tried to work on Mathscript and it is really amazing. what I tried to figure out is:     Instead of plotting using traditional "plot" statement, how to use LabVIEW chart ( I know how to Add output but the graph were not as expected

  • Howto Current System Time in the format YYYYMMDDHHMMSS

    Hi, Is there a way to calculate current system time in java so the output will be in the format YYYYMMDDHHMMSS?