Freely movable frames?

I’ve just founded your framework and IMHO its really great.

I wish to make something like Windows OS desktop for my app so my user should be able to freely move frames. Do they always have to be stick to each other side-by-side? Is there any default layout that allows arrange them in any place of the main window?

Well… the main goal of the framework is to arrange the Dockables (frames) such that there are no free spaces… so that’s not exactly what you search. You are perhaps more happy by using JInternalFrames and JDesktopPane.

But if you like the looks of the framework: there are possibilities to combine the framework with a JDestopPane, the Dockables can then float around. One of the tutorials does it, and I can write you a little example if you wish. That feature probably needs some work before it really is useable.

[QUOTE=Beni]
But if you like the looks of the framework: there are possibilities to combine the framework with a JDestopPane, the Dockables can then float around. One of the tutorials does it, and I can write you a little example if you wish. That feature probably needs some work before it really is useable.[/QUOTE]

I will be very grateful for you help! Could you please post a link to that tutorial?

Thanks in advance,
Marco

Launch the tutorial (this is a Java Webstart link)

Then go to “Basics > Core > JDesktopPane”, and hit the “startup” button.

As I said, this example has some bugs. I’ll have a look at them for the next release (maybe this or next week).
There is no example for working with the Common API (which I highly recommend), I will need to correct that as well.

Can I get the source of Chess example for the demo? Perhaps I can modified it to some kind of virtual desktop? :slight_smile:

…and I have one more question: if I use JInternalFrames to place dockables, can I still use features like exporting/importing layout to XML or closing/ reopening frames?

The code for chess is in the zip file found on the website, the path is “dock/src/docking-frames-demo-chess”. I’m not certain what you want to do with it, it sounds like a lot of work… what do you mean with virtual desktop? With icons on it?

But whatever you do, exporting/importing and closing/reopening will work when using JInternalFrames (it would be a bug if not).

I’ve made some experiments with ScreenDockStation and it appears that:

  • Sometimes after closing main application window, the Dockables still exists on the screen (it is visible even in JDesktopPane tutorial).

  • DockFrontend stores the position of the dockables, however (i think) their content is being lost. I made several ColorDockables and after save/load they lost thier „colors“…

  • I followed the JDesktop integration tutorial. When I added a ScreenDockStation object to DockFrontend, the boundary restrictions of JDesktopPane suddenly stopped working (I can now drag dockable all over the screen).

Now I’m trying SplitDockGrid. :slight_smile: It may be silly question but how can I set padding (distance) between dockables in a grid? and is it possible to prevent user form resizing rows or columns?

Is the JDesktopPane even an option for you? Because if yes, then I’ll spend some time on the weekend to address these issues…

About the size of the gap: Access the SplitDockStation which shows your Dockables, and call „setDividerSize(amount_of_pixels)“

About resizing. SplitDockStation has a method called „setResizingEnabled“ which can be used to disable resizing. I would really not recommend using that method, because the entire point of the framework is that users can resize rows and columns :wink:

[QUOTE=Beni]Is the JDesktopPane even an option for you? Because if yes, then I’ll spend some time on the weekend to address these issues…
[/QUOTE]

Yes! ScreenDockStation with boundary restriction is (at the time) the best option for me. I will be in your debt if you are so kind and address these issues.

Sorry for unregistered post. I have some difficulties with German-language layout of this forum :wink:

You can change the language with the drop-box at the lower left corner of the page.

A new version, 1.1.2p2b is online.

I would highly suggest not to work with DockFrontend but with CControl. The reason is, that CControl is from the Common API, which offers a better interface. Common more easily allows to store the content of a Dockable, and its Dockables have additional buttons like „minimize“ or „maximize“.

I’ve added a tutorial to show how Common and JDesktopPane work together: search for the class „JDesktopPaneExample“ or in the tutorial search „Basics > Common > JDesktopPane“

  • Sometimes after closing main application window, the Dockables still exists on the screen (it is visible even in JDesktopPane tutorial).

That issue should be resolved with 1.1.2p2b. The problem was that Components say there are visible even if their parent-frame is not. And during shutdown the wrong components were asked in the wrong order about their visibility.

  • DockFrontend stores the position of the dockables, however (i think) their content is being lost. I made several ColorDockables and after save/load they lost thier „colors“…

The framework always only stores the location of Dockables, never their content. How could it store the content? Guessing? :wink:
When using a DockFrontend you should register your Dockables before loading an old layout, and you are responsible for setting the content of the Dockables yourself.

When using CControl - which handles very similar to DockFrontend - you could also use „addSingleDockableFactory“ to set a factory for creating the missing dockables. And when using a „MultipleCDockable“ with a custom „MultipleCDockableFactory“ you could even tell the framework how to store the content.

Have a look at the tutorial „Guide > Common > Editors“ or the class „MultipleDockables“ to learn how to store the content of a Dockable.
Also „Basics > Common > SingleCDockableFactory“, or the class „SingleDockableFactoryExample“ could be interesting for you.

  • I followed the JDesktop integration tutorial. When I added a ScreenDockStation object to DockFrontend, the boundary restrictions of JDesktopPane suddenly stopped working (I can now drag dockable all over the screen).

I’m not certain what exactly you did, but sounds to me as if you ended up having two ScreenDockStations - one working with the JDesktopPane and one working with the screen. I would need to see the code you wrote to tell you what exactly happens.

First of all, I wish to thank you for your help and time that you spend on improving the DockingFrames. You are great. :slight_smile:

[QUOTE=Beni]
I’m not certain what exactly you did, but sounds to me as if you ended up having two ScreenDockStations - one working with the JDesktopPane and one working with the screen. I would need to see the code you wrote to tell you what exactly happens.[/QUOTE]

Here is the code. It’s just a JDesktopPane example with ScreenDockStation added to DockFrontend:

public class InternalExample {
public static void main( String args ){

  JTutorialFrame frame = new JTutorialFrame( InternalExample.class );
  
  JDesktopPane desktop = new JDesktopPane();
  frame.add( desktop );
  
  /* Creating a controller */
  DockController controller = new DockController();
  controller.setRootWindow( frame );
  frame.destroyOnClose( controller );
  
  DockProperties properties = controller.getProperties();
  properties.set( ScreenDockStation.BOUNDARY_RESTRICTION, new InternalBoundaryRestriction( desktop ) );
  properties.set( ScreenDockStation.FULL_SCREEN_STRATEGY, new InternalFullscreenStrategy( desktop ) );
  properties.set( ScreenDockStation.WINDOW_FACTORY, new InternalScreenDockWindowFactory( desktop ) );

  
  ScreenDockStation screen = new ScreenDockStation( controller.getRootWindowProvider() );
  controller.add( screen );
  
  
  
  screen.drop( new ColorDockable( "Blue", Color.BLUE ), new ScreenDockProperty( 300, 200, 100, 100 ) );
  
  frame.setVisible( true );
  screen.setShowing( true );
  
  DockFrontend front = new DockFrontend(frame);
  front.getController().setTheme(new NoStackTheme(new SmoothTheme()));
  front.setShowHideAction(true);
  front.addRoot("screen", screen);

  frame.setVisible(true);

}
}

When i run it I receive an exception and Dockables do not follow restriction properties. The exception code:

Exception in thread „AWT-EventQueue-0“ java.lang.IllegalStateException: no strategy available
at bibliothek.gui.dock.station.screen.window.DisplayerScreenDockWindow.isFullscreen(DisplayerScreenDockWindow.java:328)
at bibliothek.gui.dock.station.screen.window.AbstractScreenDockWindow$2.shapeChanged(AbstractScreenDockWindow.java:136)
at bibliothek.gui.dock.station.screen.window.DisplayerScreenDockWindow.fireShapeChanged(DisplayerScreenDockWindow.java:183)
at bibliothek.gui.dock.station.screen.window.AbstractScreenDockWindow$3.componentMoved(AbstractScreenDockWindow.java:232)
at java.awt.Component.processComponentEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

However I managed to fix this, by adding:

screen.setBoundaryRestriction(new InternalBoundaryRestriction( desktop ));
screen.setFullscreenStrategy(new InternalFullscreenStrategy( desktop ));
screen.setWindowFactory(new InternalScreenDockWindowFactory( desktop ));

No exception this time and It works as It should. I guess its not a big deal but you may be interested in it.

Actually, here comes my another question. I need to do feature like this:
One user (administrator) can arrange dockables as he wants to but other (regular) users are not supposed to change their positions and size. They can only interact with the Dockable’s content.

How can I do that? I think I just need to disable appropriate listeners of ScreenDockStation… can you tell me which ones?

You create a DockController and a DockFrontend, you should only build one of them (A DockFrontend internally creates a new instance of DockController). And very certainly you should not try to add the same “ScreenDockStation” object to both of them (I bet the exception is caused by the attempt to add “screen” two times).

Don’t create a DockController, directly build one DockFrontend.

(Or even better, use the Common API and build a CControl instead)


As for the other “feature” - which completely negates the entire point of this framework, and I do not understand why anyone would want that kind of “feature” - you can inherit a “VetoableDockRelocatorListener” and add it to:

controller.getRegister().addVetoableDockRelocatorListener( ... )```
The listener can "cancel" any event it gets, and thus prevent any drag and drop operation.

I think you meant „getRelocator()“.
Listener gets the events when I grab titles of Dockables and try to move them. However it doesn’t respond when I resize or drag them using that tight buttons around them (in ScreenDockStation):


That red „thing“.

Also I’m wondering If there is a way to make that JInternalFrames appear in front of Dockables (not in background)?

I would highly suggest not to work with DockFrontend but with CControl.

but is it possible to combine CControl and ScreenDockStation?

btw I’ve just looked at the Chess demo sources and I’m confused about hiding dockables titles. What’s the easiest way to do that?

My pathetic attempt to achieve that goal:

screen.getController().getDockTitleManager().registerTheme("GUI_NOTITLE", new DockTitleFactory(){
        	public void install( DockTitleRequest request ){
	        	// ignore	
        	}
        	
        	public void request( DockTitleRequest request ){
        		request.answer( null );
        	}
        	
        	public void uninstall( DockTitleRequest request ){
	        	// ignore	
        	}
        });

for (int i=1;i<6;i++){
			Dockable d = create();
			screen.drop( d, new ScreenDockProperty( i*120, 200, 100, 100 ));
			StationChildHandle h = new StationChildHandle(screen,screen.getDisplayers(),d,screen.getController().getDockTitleManager().getVersion("GUI_NOTITLE"));
			h.updateDisplayer();
			frame.revalidate();
		}

Of course it is possible to combine a ScreenDockStation with CControl, in fact CControl already creates one automatically. Have a look at the tutorial class “tutorial.common.basics.JDesktopPaneExample”…


About the borders of the window. They can be configured, here is an example using the Common API:


ScreenDockWindowConfiguration configuration = new ScreenDockWindowConfiguration(){
	@Override
	public WindowConfiguration getConfiguration( ScreenDockStation station, Dockable dockable ){
		WindowConfiguration window = new WindowConfiguration();
		window.setAllowDragAndDropOnTitle( false );
		window.setResizeable( false );
		window.setMoveOnBorder( false );
		window.setMoveOnTitleGrab( false );
		return window;
	}
};
control.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, configuration );

As you see, “ScreenDockWindowConfiguration” is a factory creating a “WindowConfiguration” for each window. You get the Dockable for which the configuration is used, so you could even treat windows differently depending on their content.


About the title: you should call “registerClient” instead of “registerTheme”, this will give your new factory a higher importance.

Forget the for-loop, you don’t need it. You need to use the right key(s). Instead of “GUI_NOTITLE” you should use “ScreenDockStation.TITLE_ID” (without the " ).


Now about the JInternalFrames… that’s a tricky one. Right now you will need to copy the code of “InternalScreenDockWindowFactory” and “InternalDockDialog”. In your copied InternalDockDialog there is a line “desktop.setLayer( dialog, JDesktopPane.MODAL_LAYER );”. Replace the layer with something like “JDesktopPane.DEFAULT_LAYER” (you will have to try out which parameters really work).

For the next version I’ll add a method to “InternalScreenDockWindowFactory” to preset the layer for new dialogs (will be called “setScreenDockWindowLayer”.

Great, It works like a charm (JDesktopPane.DEFAULT_LAYER worked).

However when I create my own ScreenDockWindowConfiguration I can’t drag dockables by holding they borders. I just turn setResizeable() to false because I don’t want to allow resizing and then the drag&drop border disappear. How can I make it visible and allow only to move dockables?

And I wish to make some of the dockables modal. Any work-around for it?

Do these dialogs still have a title? If so you could try “window.setMoveOnTitleGrab( true );” in your configuration. Otherwise I need some time to find a good solution (maybe the framework needs a little update).

Your “InternalDockDialog” should have a method “setDockable”, in it you could check what Dockable is shown, and then call “desktop.setLayer(…)” again.

No, they don’t. I don’t want the titles, and without them there is no „element“ for moving dockables.

Ok, I’ll add another option in the configuration (something like “move on border grab…”), and modify the border. I should find time during the weekend to do that.