Uh, the “tob” will be replaced in the next release… :o
Since the EclipseTheme normally uses gradients it mixes colors a bit. Just using one color can look very ugly. But you can easily create your own EclipseTheme which does mix the colors differently (or not at all). The code snippet below should give you all the information you need to start.
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import bibliothek.extension.gui.dock.theme.EclipseTheme;
import bibliothek.gui.DockTheme;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.intern.color.EclipseTabTransmitter;
import bibliothek.gui.dock.common.intern.theme.CDockThemeFactory;
import bibliothek.gui.dock.common.intern.theme.CEclipseTheme;
import bibliothek.gui.dock.common.layout.ThemeMap;
import bibliothek.gui.dock.common.mode.ExtendedMode;
import bibliothek.gui.dock.themes.ColorBridgeFactory;
import bibliothek.gui.dock.themes.ThemeFactory;
import bibliothek.gui.dock.themes.ThemePropertyFactory;
import bibliothek.gui.dock.themes.color.TabColor;
import bibliothek.gui.dock.util.color.ColorBridge;
import bibliothek.gui.dock.util.color.ColorManager;
public class Dock9 {
public static SingleCDockable createDockable( String title, Color color ){
JPanel panel = new JPanel();
panel.setOpaque(true);
panel.setBackground(color);
DefaultSingleCDockable dockable = new DefaultSingleCDockable(title, title, panel);
dockable.setDefaultLocation(ExtendedMode.MINIMIZED, CLocation.base().minimalEast());
dockable.setDefaultLocation(ExtendedMode.EXTERNALIZED, CLocation.external(0, 0, 300, 300));
return dockable;
}
public static void main( String[] args ){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
JFrame frame = new JFrame("Demo");
CControl control = new CControl(frame);
frame.add(control.getContentArea(), BorderLayout.CENTER);
CGrid grid = new CGrid(control);
grid.add(1, 0, 1, 1, createDockable("Green", Color.GREEN));
grid.add(1, 1, 1, 1, createDockable("Blue", Color.BLUE));
grid.add(0, 0, 1, 1, createDockable("Red", Color.RED));
grid.add(0, 1, 1, 1, createDockable("Yellow", Color.YELLOW));
control.getContentArea().deploy(grid);
/*
* Access the ThemeMap and replace the factory for the EclipseTheme
*/
ThemeMap themes = control.getThemes();
ThemeFactory eclipse = new CDockThemeFactory<EclipseTheme>(new ThemePropertyFactory<EclipseTheme>(EclipseTheme.class), control){
@Override
public DockTheme create( CControl control ){
return new CCustomEclipseTheme(control);
}
};
themes.put(ThemeMap.KEY_ECLIPSE_THEME, eclipse);
control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(20, 20, 400, 400);
frame.setVisible(true);
}
});
}
/*
* Our custom EclipseTheme sets its custom EclipseTabTransmitter
*/
private static class CCustomEclipseTheme extends CEclipseTheme {
public CCustomEclipseTheme( CControl control ){
super(control, new EclipseTheme());
putColorBridgeFactory(TabColor.KIND_TAB_COLOR, new ColorBridgeFactory(){
public ColorBridge create( ColorManager manager ){
return new CustomEclipseTabTransmitter(manager);
}
});
}
}
/*
* This class just has to implement the interface "ColorBridge". But extending
* EclipseTabTransmitter is much easier. The class is completely free in how it
* handles the different colors.
*/
private static class CustomEclipseTabTransmitter extends EclipseTabTransmitter {
public CustomEclipseTabTransmitter( ColorManager manager ){
super(manager);
}
// this method is called for any CDockable
@Override
protected Color get( Color color, String id, CDockable dockable ){
Color result = super.get(color, id, dockable);
if( result == color ){
result = new Color( 255-color.getRed(), 255-color.getGreen(), 255-color.getBlue() );
}
return result;
}
// these methods are only called
// - if the color is set in the ColorMap of a CDockable AND
// - if the method "get" is not overridden.
@Override
protected Color convert( Color source, String key ){
System.out.println( key );
return new Color(255, source.getGreen(), source.getBlue());
}
@Override
protected Color convertFocused( Color source, String key ){
System.out.println( key );
return new Color(source.getRed(), 255, source.getBlue());
}
@Override
protected Color convertSelected( Color source, String key ){
System.out.println( key );
return new Color(source.getRed(), source.getGreen(), 255);
}
}
}```