Hello,
is it possible to change or remove the border in the working area of a CControl?
Please see the screenshot. There is a raised bevel border around the empty working area and around the left docks. That is with the flat theme.
What I really find strange is that there is BORDER_MODIFIER in DockTheme,
but neither FlatTheme nor BasicTheme are set a BevelBorder anywhere. Also EclipseTheme is not set any border.
So where is this border set? It must be in the theme, because the EclipseTheme does not show this border.
It is possible. The border is actually created by objects of type “DockableDisplayer”, and these objects depend on the theme.
Run the example below, it will disable the borders.
import javax.swing.JFrame;
import javax.swing.border.Border;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.CWorkingArea;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.intern.CommonDockable;
import bibliothek.gui.dock.displayer.DisplayerDockBorder;
import bibliothek.gui.dock.themes.ThemeManager;
import bibliothek.gui.dock.themes.border.BorderModifier;
import bibliothek.gui.dock.util.UIBridge;
import bibliothek.gui.dock.util.UIValue;
public class NoBorder {
public static void main( String[] args ){
/* creating a frame and control... */
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setBounds( 20, 20, 400, 400 );
CControl control = new CControl(frame);
/* access the "ThemeManager", it is responsible for handling many properties that have an effect on the ui */
ThemeManager themeManager = control.getController().getThemeManager();
/* The Border of any Dockable is painted by its DockableDisplayer. The DockableDisplayer in return requests
* a BorderModifier to change its border. This request is represented by an object of type "DisplayerDockBorder".
* By calling "setBorderModifierBrige" we intercept these requests and can answer them ourselfs. */
themeManager.setBorderModifierBridge( DisplayerDockBorder.KIND, new NoBorderModifierBridge() );
/* and we just add some content to the JFrame */
frame.add( control.getContentArea() );
DefaultSingleCDockable dockable = new DefaultSingleCDockable( "id", "Title" );
control.addDockable( dockable );
dockable.setVisible( true );
CWorkingArea work = control.createWorkingArea( "work" );
work.setLocation( CLocation.base().normalEast( 0.75 ) );
work.setVisible( true );
frame.setVisible( true );
}
/* The "UIBrige" is responsible for answering requests for properties that are used in the framework. This
* bridge will answer requests for "BorderModifiers". */
private static class NoBorderModifierBridge implements UIBridge<BorderModifier, UIValue<BorderModifier>>{
@Override
public void add( String id, UIValue<BorderModifier> uiValue ){
/* We could use the add and remove mothod to remember requests and answer them a second time. But
* there is no need for that for the current task. */
// ignore
}
@Override
public void remove( String id, UIValue<BorderModifier> uiValue ){
// ignore
}
@Override
public void set( String id, BorderModifier value, UIValue<BorderModifier> uiValue ){
/* This is a safe cast, because of the arguments we used when registering this brige. */
DisplayerDockBorder displayerDockBorder = (DisplayerDockBorder)uiValue;
/* "uiValue" represents the request for a property, "value" is the default value, "id" is the
* the name of the property.
* "uiValue" tells us for which Dockable the property is requested... */
Dockable dockable = displayerDockBorder.getDisplayer().getDockable();
if( dockable instanceof CommonDockable ){
CDockable cdockable = ((CommonDockable)dockable).getDockable();
if( cdockable.asStation() instanceof CWorkingArea ){
/* ... and if the property is requested for a CWorkingArea, we set the "NoBorderModifier" */
value = new NoBorderModifier();
}
}
uiValue.set( value );
}
}
/* The "NoBorderModifier" replaces any border with "null" */
private static class NoBorderModifier implements BorderModifier{
@Override
public Border modify( Border border ){
return null;
}
}
}
yes thank you that works. But what about the left docks?
Your code is removing the border around the working area, but how about the border around the docks on the left?