I am using the “flat” theme where the title of a dockable is shown in addition to the same text of the chosen tab of the tabbedpane. That wastes screen area and looks unprofessional. The “Eclipse” theme is doing better, by hiding the title in this situation. May I ask for a hint to change the flat theme behaviour appropriately.
You can add some configuration to make the “flat” theme behave like the “Eclipse” theme. In the example below all the titles are disabled. Having sometimes titles and sometimes tabs looks really ugly, so I did not even bother searching for a setting that would allow that (but it would be possible).
import javax.swing.JFrame;
import bibliothek.extension.gui.dock.theme.FlatTheme;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.action.DockAction;
import bibliothek.gui.dock.action.DockActionSource;
import bibliothek.gui.dock.action.FilteredDockActionSource;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.facile.action.CloseAction;
import bibliothek.gui.dock.station.stack.action.DefaultDockActionDistributor;
import bibliothek.gui.dock.station.stack.tab.layouting.TabPlacement;
public class TabExample {
public static void main( String[] args ) {
JFrame frame = new JFrame( "title" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
CControl control = new CControl( frame );
frame.add( control.getContentArea() );
control.setTheme( ThemeMap.KEY_FLAT_THEME );
// use single-tab-shown and title-shown to switch behavior
DefaultSingleCDockable d1 = new DefaultSingleCDockable( "d1", "abc" );
d1.setSingleTabShown( true );
d1.setTitleShown( false );
d1.setCloseable( true );
DefaultSingleCDockable d2 = new DefaultSingleCDockable( "d2", "def" );
d2.setSingleTabShown( true );
d2.setTitleShown( false );
d2.setCloseable( true );
DefaultSingleCDockable d3 = new DefaultSingleCDockable( "d3", "ghj" );
d3.setSingleTabShown( true );
d3.setTitleShown( false );
d3.setCloseable( true );
// move tab to the top
control.putProperty( StackDockStation.TAB_PLACEMENT, TabPlacement.TOP_OF_DOCKABLE );
// decide which buttons to show directly on the tabs
control.putProperty( FlatTheme.ACTION_DISTRIBUTOR,
new DefaultDockActionDistributor() {
@Override
protected DockActionSource createInfoSource( DockActionSource source ) {
return new FilteredDockActionSource( source ) {
@Override
protected boolean include( DockAction action ) {
return !isCloseAction( action );
}
};
}
@Override
protected DockActionSource createTabSource( DockActionSource source ) {
return new FilteredDockActionSource( source ) {
@Override
protected boolean include( DockAction action ) {
return isCloseAction( action );
}
};
}
private boolean isCloseAction( DockAction action ) {
// that is a bit of a hack, but it works
return action instanceof CloseAction;
}
} );
CGrid grid = new CGrid( control );
grid.add( 0, 0, 1, 1, d1 );
grid.add( 1, 0, 1, 1, d2, d3 );
control.getContentArea().deploy( grid );
frame.setBounds( 50, 50, 800, 800 );
frame.setVisible( true );
}
}