Toolbar border

Hello,

Is it possible to remove the black border around the toolbar including the black oval at the start of the first toolbar.
(See the attached preview)

Changing the gap and/or background dit not help.

Thanks.

Welcome to the forum.

but this forum is bound to german users.
If you need help in english language you should go here:
https://forums.oracle.com/community/developer/english/java/java_essentials

besides:
I’d start by setting an empty border…

bye
TT

Not really. This part of the forum is international and belongs to the Docking Frames project.
I would guess the to is using this framework and so this is the right place for his question.

[QUOTE=Tomate_Salat;76223]Not really. This part of the forum is international and belongs to the Docking Frames project. [/QUOTE]Then I’m sorry, no offence was intended…

bye
TT

It is possible to customize these things, but the framework does only offer one default style for these lines. However you want to customize them - you are going to write some painting code of your own.

This example may give you a hint where to start:


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

import javax.swing.JComponent;
import javax.swing.JFrame;

import bibliothek.gui.dock.ToolbarContainerDockStation;
import bibliothek.gui.dock.ToolbarGroupDockStation;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.action.CButton;
import bibliothek.gui.dock.station.screen.ScreenToolbarDockTitleFactory;
import bibliothek.gui.dock.station.toolbar.group.ToolbarGroupDividerStrategy;
import bibliothek.gui.dock.station.toolbar.group.ToolbarGroupDividerStrategyFactory;
import bibliothek.gui.dock.station.toolbar.group.ToolbarGroupTitle;
import bibliothek.gui.dock.title.DockTitle;
import bibliothek.gui.dock.title.DockTitleFactory;
import bibliothek.gui.dock.title.DockTitleManager;
import bibliothek.gui.dock.title.DockTitleRequest;
import bibliothek.gui.dock.toolbar.CToolbarContentArea;
import bibliothek.gui.dock.toolbar.CToolbarItem;
import bibliothek.gui.dock.toolbar.location.CToolbarAreaLocation;
import bibliothek.gui.dock.util.Priority;
import bibliothek.gui.dock.util.color.ColorManager;

public class ToolbarCustomization {
	public static void main( String[] args ) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
		CControl control = new CControl( frame );
		
		// change the color of the title (the black round thing)
		// does not work in 1.1.2p10, will need an update to 1.1.2p10a
		ColorManager colors = control.getController().getColors();
		colors.put( Priority.CLIENT, "extension.toolbar.group.title", Color.RED );
		
		// completely disable all black lines. If you want more customization, then you need to write
		// your own ToolbarGroupDividerStrategy
		control.putProperty( ToolbarGroupDockStation.DIVIDER_STRATEGY_FACTORY, dividerStrategyFactory() );
		
		// This way the title (black round thing) can be replaced with a custom component that paints however
		// you want. It is also possible to not set a title at all, using the factory "NullTitleFactory.INSTANCE"
		DockTitleManager titles = control.getController().getDockTitleManager();
		titles.registerTheme( ToolbarContainerDockStation.TITLE_ID, customToolbarTitleFactory() );
		titles.registerTheme( ScreenToolbarDockTitleFactory.TITLE_ID, customToolbarTitleFactory() );
		
		
		CToolbarContentArea area = new CToolbarContentArea( control, "area" );
		control.addStationContainer( area );
		frame.add( area );
		
        CToolbarAreaLocation location = area.getNorthToolbar().getStationLocation();
		
        add( control, "A",    location.group( 0 ).toolbar( 0, 0 ).item( 0 ) );
        add( control, "B",    location.group( 0 ).toolbar( 0, 0 ).item( 1 ) );
        add( control, "C",    location.group( 0 ).toolbar( 0, 0 ).item( 2 ) );
        
        add( control, "D",  location.group( 0 ).toolbar( 0, 1 ).item( 0 ) );
        add( control, "E",  location.group( 0 ).toolbar( 0, 1 ).item( 1 ) );
        add( control, "F",  location.group( 0 ).toolbar( 0, 1 ).item( 2 ) );
        
        add( control, "G",   location.group( 0 ).toolbar( 1, 0 ).item( 0 ) );
        
        frame.setBounds( 20, 20, 600, 400 );
        frame.setVisible( true );
	}
	
	// factory for creating customized title
    private static DockTitleFactory customToolbarTitleFactory() {
		return new DockTitleFactory() {
			@Override
			public void uninstall( DockTitleRequest request ) {
				// ignore	
			}
			
			@Override
			public void request( DockTitleRequest request ) {
				request.answer( customToolbarTitle( request ) );
			}
			
			@Override
			public void install( DockTitleRequest request ) {
				// ignore
			}
		};
	}

    // method creating a customized title
	private static DockTitle customToolbarTitle( DockTitleRequest request ) {
		return new ToolbarGroupTitle( request.getTarget(), request.getVersion() ){
			@Override
			public void paintBackground( Graphics g, JComponent component ) {
				g.setColor( Color.GREEN );
				g.fillRect( 0, 0, getWidth(), getHeight() );
			}
		};
	}

	// method creating a factory for installing customized line painting code 
	private static ToolbarGroupDividerStrategyFactory dividerStrategyFactory() {
    	return new ToolbarGroupDividerStrategyFactory() {
			@Override
			public ToolbarGroupDividerStrategy create( ToolbarGroupDockStation station ) {
				return ToolbarGroupDividerStrategy.NULL;
			}
		};
	}

	// just add some items to test the settings
	private static void add( CControl control, String id, CLocation location ){
        CToolbarItem item = new CToolbarItem( id );
        
        CButton button = new CButton( id, null );
        button.setShowTextOnButtons( true );
        item.setItem( button );
        
        item.setLocation( location );
        control.addDockable( item );
        item.setVisible( true );
    }
}

Hi Beni,

This is exactly what I need. I don’t want titles at all (yet).
Since Swing does not give users the flexibility to customize the toolbars and multiple toolbars is not default available, I like DF most.

Thanks for this framework and keep up the good work!