Software developer

Hi,

First I would like to say that Docking Frames is great! I really appreciate this library.

Here is the problem that I found using Core:

When I write a layout to disk in a binary file, and that I read it back using DockFrontend, the y positions of the Dockables are not restored when I reload the layout, although the X positions are restored correctly.

For instance, take two Dockables, one at north and one at south, each one using 50% of the Y space.
If you move the vertical split between both to give 20% of the Y space to one and 80% to the other, then
when the layout is saved/written before to close the application and re-read/loaded after starting the application, the distribution is back to 50% to each one. For the X distribution I do not see this problem.

I fixed the title :o

[QUOTE=MDubuc]Hi,

First I would like to say that Docking Frames is great! I really appreciate this library.

Here is the problem that I found using Core:

When I write a layout to disk in a binary file, and that I read it back using DockFrontend, the y positions of the Dockables are not restored when I reload the layout, although the X positions are restored correctly.

For instance, take two Dockables, one at north and one at south, each one using 50% of the Y space.
If you move the vertical split between both to give 20% of the Y space to one and 80% to the other, then
when the layout is saved/written before to close the application and re-read/loaded after starting the application, the distribution is back to 50% to each one. For the X distribution I do not see this problem.[/QUOTE]

I am using 1.1.0p7b

Ok, I’ll have a look at this bug (not today but within the weekend). I did not use the binary format for some time, so I would not have noticed.

I could not confirm this bug, my test application below works as expected.

Is it possible that your application has some Components with a minimum size set? Because the framework tries to ensure that any Dockable is never smaller than “Component.getMinimumSize”, and if there is not enough space the Dockables all get the same amount of space (50%).


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JFrame;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.station.split.SplitDockProperty;

public class Dock66 {
	public static void main( String[] args ){
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
		SplitDockStation station = new SplitDockStation();
		final DockFrontend frontend = new DockFrontend( frame );
		frontend.addRoot( "root", station );
		
		frame.add( station );
		
		DefaultDockable a = new DefaultDockable("a");
		DefaultDockable b = new DefaultDockable("b");
		
		frontend.addDockable( "a", a );
		frontend.addDockable( "b", b );
		
		station.drop( a );
		station.drop( b, SplitDockProperty.NORTH );
		
		JButton button = new JButton("reload");
		a.add( button );
		button.addActionListener( new ActionListener(){
			@Override
			public void actionPerformed( ActionEvent e ){
				try{
					ByteArrayOutputStream out = new ByteArrayOutputStream();
					frontend.write( new DataOutputStream( out ) );
					frontend.read( new DataInputStream( new ByteArrayInputStream( out.toByteArray() ) ) );
				}
				catch( IOException ex ){
					ex.printStackTrace();
				}
			}
		});
		
		frame.setBounds( 20, 20, 500, 400 );
		frame.setVisible( true );
	}
}```

:slight_smile:
Your test application has been quite useful. I have found what is creating the problem in my application. This is the call to frame.pack (). If you just add this line of code in your test application you will see the problem.

I added frame.pack () in it, just before the following lines:
frame.setBounds( 20, 20, 500, 400 );
frame.setVisible( true );

Should I avoid to use pack () ?

Thank you!

Most Components of the framework do not implement “getPreferredSize” and “getMinimumSize”, as a result the method “pack” does not work well. I would just not call pack, setting the size directly should be easy enough for most applications.