Set station background color


#1

Hello,

I use the Eclipse theme of docking frame 1.1.2. I found how to change the Tab foreground and background, nevertheless I didn’t found how to change the Station background, i.e., the space behind the Tabs where the close Maximize and Minimize buttons are.

It seems that the color is inherited from the Java LookAndFeel background color but I don’t want to change this.

I found that this is an object of the StackDockStation class with a path “dock.background.station.stack”. Can I change the color using this path?

Best regards,
Amaury


#2

Not every Dockable is a child of a StackDockStation. But in the EclipseTheme every Dockable is a child of an EclipseTabPane. And there is a mechanism to replace the default painting code of the EclipseTabPane. So how about something like this?

The code below does just paint the entire background red, but you don’t see the entire background because there are some Dockables in the way.

package test;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;

import javax.swing.JFrame;

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.themes.ThemeManager;
import bibliothek.gui.dock.util.BackgroundComponent;
import bibliothek.gui.dock.util.BackgroundPaint;
import bibliothek.gui.dock.util.PaintableComponent;
import bibliothek.gui.dock.util.Transparency;

public class EclipseTabBackgroundTest {
	public static void main( String[] args ) {
		JFrame frame = new JFrame( "Test" );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

		CControl control = new CControl( frame );
		frame.add( control.getContentArea() );
		control.setTheme( ThemeMap.KEY_ECLIPSE_THEME );

		control.getController().getThemeManager().setBackgroundPaint(
				ThemeManager.BACKGROUND_PAINT + ".tabPane",
				new MyBackground() );

		CGrid grid = new CGrid( control );
		grid.add( 0, 0, 1, 1,
				new DefaultSingleCDockable( "1", "One" ),
				new DefaultSingleCDockable( "2", "Two" ) );
		grid.add( 1, 0, 1, 1,
				new DefaultSingleCDockable( "3", "Three" ) );

		control.getContentArea().deploy( grid );
		frame.setBounds( 50, 50, 1000, 1000 );
		frame.setVisible( true );
	}

	private static class MyBackground implements BackgroundPaint {
		@Override
		public void install( BackgroundComponent component ) {
			component.setTransparency( Transparency.SOLID );
		}

		@Override
		public void uninstall( BackgroundComponent component ) {
			component.setTransparency( Transparency.DEFAULT );
		}

		public void paint( BackgroundComponent background, PaintableComponent paintable, Graphics g ) {
			// ignore default background
			paintable.paintBackground( null );

			// paint custom background
			Component c = paintable.getComponent();
			g.setColor( Color.RED );
			g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
		}
	}
}


#3

Beni, thanks a lot, this totally solves my problem :slight_smile: