Add docable to workArea without change selected tabs

Hi,
how can I add docable to workArea without change current tab selection.

work.addDocable(d);
d.setVisible(true);

Docable d is wisbile now and tabs with docable going to front.
When I add many docable with long time for repaint its canvas, setVisible is long.
I don’t wont to change current tabs when i setVisible docable.

How can I do that?

Thanks for answer.

From my point of view “with long time for repaint its canvas” sounds like something that is wrong anyway. Is there no possibility to solve this e.g. use some picture to buffer the content? A tab popping up anywhere will lead to a “repaint()” in any case…

There is a FocusVetoListener which can be added to the FocusController (DockController.getFocusController). It might help, but I’m not entirely sure if in your case the tabs wouldn’t switch anyway (some events cannot be vetoed). I can give you a better answer (maybe with an example) tomorrow.

Thanks, I will waiting for a example.

I use FocusVetoListener and it doesn’t help.

I open a file and rendering its content long time.
User can open more files one time.
I this case I wont to open first file, render view and add content to docable and show this docable.
Second file will be opened and render in thread bat first I add docable with empty content and I don’t wont
show this tabs - the first tab is in front. Content form second tab willbe rendered in background.

It’s a bit more complex than I thought. I’ve added a new property “StackDockStation.IMMUTABLE_SELECTED_INDEX” which tells the framework not to switch the index. Unfortunately that won’t prevent Swing from sending a repaint event anyway, your code may have to check the visibility of the Dockable before actually painting. But the repaint event should be too late for any confusion - i.e. the Component may be visible for a short amount of time, but the first repaint event will arrive after the Component has already been made invisible again.

I’ll upload a new release later this day (I have to clean up some code first), and I’ll write in this thread again once it is ready. For now, here is some testing code that shows how you’ll need to set up the framework:


import javax.swing.JFrame;

import bibliothek.gui.Dockable;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.common.CContentArea;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.control.focus.FocusController;
import bibliothek.gui.dock.event.FocusVetoListener;
import bibliothek.gui.dock.title.DockTitle;

public class Dock81 {
	public static void main( String[] args ){
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		CControl control = new CControl( frame );
		CContentArea area = control.getContentArea();
		frame.add( area );

		/* You should run this code before calling "setVisible", and afterwards 
		 * set the property back to false and remove the listener */
		
		/* Tell the StackDockStation not to switch the selected index automatically */
		control.putProperty( StackDockStation.IMMUTABLE_SELECTION_INDEX, true );
		
		/* Tell the FocusManager not to switch focus automatically */
		control.getController().getFocusController().addVetoListener( new FocusVetoListener(){
			@Override
			public FocusVeto vetoFocus( FocusController controller, Dockable dockable ){
				return FocusVeto.VETO;
			}
			@Override
			public FocusVeto vetoFocus( FocusController controller, DockTitle title ){
				return FocusVeto.NONE;
			}
		});

		/* Move these items around and see, how the selected Dockable never changes */
		CGrid grid = new CGrid( control );
		grid.add( 0, 0, 1, 1, new DefaultSingleCDockable( "a", "A" ) );
		grid.add( 1, 0, 1, 1, new DefaultSingleCDockable( "b", "B" ) );
		grid.add( 0, 1, 1, 1, new DefaultSingleCDockable( "c", "C" ) );
		grid.add( 1, 1, 1, 1, new DefaultSingleCDockable( "d", "D" ) );
		area.deploy( grid );
		
		frame.setBounds( 20, 20, 400, 400 );
		frame.setVisible( true );
	}
}```

The new release is online.

Thank you for help and fast answer.
It’s work great :slight_smile:

This framework is the best.

I apologize for my poor english.