How do I change the way an externalised window drags, when you click on a JFRame and drag it you see the window drag. When you click on a dockable and drag it only the mouse pointer moves and when you release the pointer it moves the window.
This behavior is currently not available in the master branch. However, the “Toolbar” branch contains this feature. In order to use it, you will need to download the source directly from Github, and make sure to compile the Toolbar branch.
Once done, you will see that ScreenDockStation has a property-key WINDOW_CONFIGURATION. Use “ccontrol.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, )”, where is a subclass of “ScreenDockWindowConfiguration”. This has one method, this method has to create one new “WindowConfiguration”, has to call “setMoveOnTitleGrab(true)”, and return the new configuration.
Hi so I downloaded toolBar and found the
DefaultScreenDockWindowConfiguration defaultScreenDockWindowConfiguration = new DefaultScreenDockWindowConfiguration(control.getController());
control.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, defaultScreenDockWindowConfiguration);
But the factory does not have that method, is there another class?
You can’t use the DefaultScreenDockWindowConfiguration, you need to write your own configuration. Like this:
@Override
public WindowConfiguration getConfiguration( ScreenDockStation station, Dockable dockable ){
WindowConfiguration configuration = new WindowConfiguration();
configuration.setMoveOnTitleGrab(true);
//configuration.setAllowDragAndDropOnTitle(true);
//configuration.setResetOnDropable(false);
//configuration.setResizeable(false);
//configuration.setTransparent( true );
return configuration;
}
}```
Some of the names may still change before I merge the branch with master... but you will notice that without any doubt ;-)
Thanks, gave it a try but the docking seems to null pointer when I try and drag the window out of the main frame. Maybe I should wait until this makes it into trunk?
Sorry, I was not around yesterday. What exactly does the exception say? Because I don’t see any exceptions in my test-application (see below).
import javax.swing.JFrame;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.ScreenDockStation;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.station.screen.ScreenDockWindowConfiguration;
import bibliothek.gui.dock.station.screen.window.WindowConfiguration;
public class WindowTest {
public static void main( String[] args ){
JFrame frame = new JFrame( "Test" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setBounds( 20, 20, 300, 300 );
CControl control = new CControl( frame );
frame.add( control.getContentArea() );
DefaultSingleCDockable a = new DefaultSingleCDockable( "a", "AAA" );
DefaultSingleCDockable b = new DefaultSingleCDockable( "b", "BBB" );
control.addDockable( a );
control.addDockable( b );
a.setLocation( CLocation.base().normal() );
a.setVisible( true );
b.setLocation( CLocation.base().normalSouth( 0.5 ) );
b.setVisible( true );
control.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, new ScreenDockWindowConfiguration(){
@Override
public WindowConfiguration getConfiguration( ScreenDockStation station, Dockable dockable ){
WindowConfiguration config = new WindowConfiguration();
config.setMoveOnTitleGrab( true );
return config;
}
});
frame.setVisible( true );
}
}
Thanks for the reply. I did get the ToolBar branch, and ran an mvn clean install took the jars into eclipse. When I run it i get
Exception in thread “main” java.lang.NoSuchFieldError: WINDOW_CONFIGURATION
at com.celertech.web.orderrouting.client.Test.main(Test.java:33)
There is no longer any support for maven… there is a good chance you have the wrong/old JARs installed. Sorry, you must run the “build.xml” ANT file manually if you want JARs (the file can be found in the core project).
Yup works well. When will these changes get into trunk?
I spoke with Herve and we both agreed on “soon”. I already started with preparations, like writing some tutorials on how to use the toolbars. My plan is to have it included in 1.1.1p8, but I really can’t tell you the date.
Just tried this configuration with the Eclipse theme. And you can’t drag the title bar as it is a tab, it will drag but only when you release the mouse
import bibliothek.extension.gui.dock.theme.EclipseTheme;
import bibliothek.extension.gui.dock.theme.eclipse.stack.tab.RectGradientPainter;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.ScreenDockStation;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.station.screen.ScreenDockWindowConfiguration;
import bibliothek.gui.dock.station.screen.window.WindowConfiguration;
import bibliothek.gui.dock.station.stack.tab.DefaultTabContentFilter;
import bibliothek.gui.dock.station.stack.tab.DefaultTabContentFilter.Behavior;
public class WindowTest {
public static void main( String[] args ){
JFrame frame = new JFrame( "Test" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setBounds( 20, 20, 300, 300 );
CControl control = new CControl( frame );
frame.add( control.getContentArea() );
DefaultSingleCDockable a = new DefaultSingleCDockable( "a", "AAA" );
DefaultSingleCDockable b = new DefaultSingleCDockable( "b", "BBB" );
control.addDockable( a );
control.addDockable( b );
a.setLocation( CLocation.base().normal() );
a.setVisible( true );
b.setLocation( CLocation.base().normalSouth( 0.5 ) );
b.setVisible( true );
ThemeMap themes = control.getThemes();
themes.select(ThemeMap.KEY_ECLIPSE_THEME);
control.putProperty( EclipseTheme.TAB_PAINTER, RectGradientPainter.FACTORY );
control.putProperty( EclipseTheme.PAINT_ICONS_WHEN_DESELECTED, true );
control.putProperty( StackDockStation.TAB_CONTENT_FILTER, new DefaultTabContentFilter(Behavior.TEXT_ONLY) );
control.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, new ScreenDockWindowConfiguration(){
public WindowConfiguration getConfiguration( ScreenDockStation station, Dockable dockable ){
WindowConfiguration config = new WindowConfiguration();
config.setMoveOnTitleGrab( true );
return config;
}
});
frame.setVisible( true );
}
}
It will also not work if you stack several dockables (and it can never work, because otherwise you would not be able to separate them). But I’ll write some code to support the case with only one tab.
Just a note when running with the eclipse theme and tabs the drag does not work as well. I think this might be due to the fact that you don’t have a toolbar just a tab.
import javax.swing.JFrame;
public class WindowTest {
public static void main( String[] args ){
JFrame frame = new JFrame( "Test" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setBounds( 20, 20, 300, 300 );
CControl control = new CControl( frame );
frame.add( control.getContentArea() );
DefaultSingleCDockable a = new DefaultSingleCDockable( "a", "AAA" );
DefaultSingleCDockable b = new DefaultSingleCDockable( "b", "BBB" );
control.addDockable( a );
control.addDockable( b );
a.setLocation( CLocation.base().normal() );
a.setVisible( true );
b.setLocation( CLocation.base().normalSouth( 0.5 ) );
b.setVisible( true );
ThemeMap themes = control.getThemes();
themes.select(ThemeMap.KEY_ECLIPSE_THEME);
control.putProperty( EclipseTheme.TAB_PAINTER, RectGradientPainter.FACTORY );
control.putProperty( EclipseTheme.PAINT_ICONS_WHEN_DESELECTED, true );
control.putProperty( StackDockStation.TAB_CONTENT_FILTER, new DefaultTabContentFilter(Behavior.TEXT_ONLY) );
control.putProperty( ScreenDockStation.WINDOW_CONFIGURATION, new ScreenDockWindowConfiguration(){
public WindowConfiguration getConfiguration( ScreenDockStation station, Dockable dockable ){
WindowConfiguration config = new WindowConfiguration();
config.setMoveOnTitleGrab( true );
return config;
}
});
frame.setVisible( true );
}
}
I’ve uploaded a new version to Github, this one supports moving windows when grabbing the tab (and only the tab).
I fixed at least one bug, could be that this was your problem. But if not, can you please describe what happens - and what you think should happen?
works like a charm, thank you.