CWorkingArea

Hi,

How can I add a dockable to a CWorkingArea by index?
Is their also any way to retrieve the dockable at a specific index?

Thank you

As written in the other thread, a CWorkingArea is not a stack, hence the answer is clearly “no”. You can use “CDockable.getBaseLocation” to get the location of a Dockable and then use “CLocation.aside” or “stack” to put another Dockable in the same stack (or at least near) the first one.

Getting a Dockable by a location is not implemented, mostly because the location may change at any time. To find the location you would already need to know the Dockable…

Why would you need this functionality, what should your application do? Perhaps there is an easier way to achieve the same goal.

Hi,

I have a dymanic GUI component builder, and my API allows the user to insert /update/delete a tab element by index

I need to know each tabItem is at which position.

Is their any other way to do it?

Thank you

Hi,

In my below [static] example, I have 3 dockables, Red, Green, and Blue.
I want to insert initially the “Red Dockable” at the first position, then to insert the “Green Dockable” at the second position and finally I want to insert the “Blue Dockable” at the first position

Any advice how to achieve my result?


 
**[SIZE=2]import [/SIZE]**java.awt.BorderLayout;

[LEFT]**[SIZE=2]import [/SIZE]**java.awt.Color;[/LEFT]

**[SIZE=2]import [/SIZE]**java.awt.event.ActionEvent;

**[SIZE=2]import [/SIZE]**java.awt.event.ActionListener;

**[SIZE=2]import [/SIZE]**javax.swing.JButton;

**[SIZE=2]import [/SIZE]**tutorial.support.ColorSingleCDockable;

**[SIZE=2]import [/SIZE]**tutorial.support.JTutorialFrame;

**[SIZE=2]import [/SIZE]**bibliothek.gui.dock.common.CControl;

**[SIZE=2]import [/SIZE]**bibliothek.gui.dock.common.CLocation;

**[SIZE=2]import [/SIZE]**bibliothek.gui.dock.common.CWorkingArea;

**[SIZE=2]import [/SIZE]**bibliothek.gui.dock.common.DefaultSingleCDockable;

 
[LEFT]**[SIZE=2]public [/SIZE]****[SIZE=2]class[/SIZE]** CWorkingAreaExample {[/LEFT]
 
 

[LEFT]**[SIZE=2]private [/SIZE]****[SIZE=2]static[/SIZE]****[SIZE=2]final[/SIZE]** String **[SIZE=2]INSERT_GREEN_DOCKABLE[/SIZE]** = [SIZE=2]"Insert Green Dockable"[/SIZE];
[LEFT]**[SIZE=2]private [/SIZE]****[SIZE=2]static[/SIZE]****[SIZE=2]final[/SIZE]** String **[SIZE=2]INSERT_RED_DOCKABLE[/SIZE]** = [SIZE=2]"Insert Red Dockable"[/SIZE];
**[SIZE=2]private [/SIZE]****[SIZE=2]static[/SIZE]****[SIZE=2]final[/SIZE]** String **[SIZE=2]INSERT_BLUE_DOCKABLE[/SIZE]** = [SIZE=2]"Insert Blue Dockable"[/SIZE];[/LEFT]
[/LEFT]

 

[LEFT]**[SIZE=2]public [/SIZE]****[SIZE=2]static [/SIZE]****[SIZE=2]void[/SIZE]** main( String[] args ){
[LEFT]JTutorialFrame frame = **[SIZE=2]new[/SIZE]** JTutorialFrame( CWorkingAreaExample.**[SIZE=2]class[/SIZE]** );
CControl control = **[SIZE=2]new[/SIZE]** CControl( frame );
frame.destroyOnClose( control );
**[SIZE=2]final[/SIZE]** CWorkingArea workingArea = control.createWorkingArea([SIZE=2]"workingarea"[/SIZE]);
frame.add(workingArea.getComponent(), BorderLayout.**[SIZE=2]CENTER[/SIZE]**);[/LEFT]
[/LEFT]

 

[LEFT]**[SIZE=2]final[/SIZE]** JButton redBtn = **[SIZE=2]new[/SIZE]** JButton(**[SIZE=2]INSERT_RED_DOCKABLE[/SIZE]**);
[LEFT]redBtn.addActionListener(**[SIZE=2]new[/SIZE]** ActionListener() {[/LEFT]
[/LEFT]

 

[LEFT][SIZE=2]@Override[/SIZE]
[LEFT]**[SIZE=2]public[/SIZE]****[SIZE=2]void[/SIZE]** actionPerformed(ActionEvent actionEvent) {
String text = redBtn.getText();
**[SIZE=2]if[/SIZE]**(text.equals(**[SIZE=2]INSERT_GREEN_DOCKABLE[/SIZE]**)) {
  DefaultSingleCDockable green = **[SIZE=2]new[/SIZE]** ColorSingleCDockable( [SIZE=2]"Green"[/SIZE], Color.**[SIZE=2]GREEN[/SIZE]** );
  green.setLocation( CLocation.**working**( workingArea ).rectangle( 0, 0, 1, 1 ) );
  workingArea.add(green);
  green.setVisible( **[SIZE=2]true[/SIZE]** );
  redBtn.setText(**[SIZE=2]INSERT_BLUE_DOCKABLE[/SIZE]**);[/LEFT]
[/LEFT]

 

[LEFT]} **[SIZE=2]else[/SIZE]****[SIZE=2]if[/SIZE]** (text.equals(**[SIZE=2]INSERT_BLUE_DOCKABLE[/SIZE]**)) {
[LEFT]  DefaultSingleCDockable blue = **[SIZE=2]new[/SIZE]** ColorSingleCDockable( [SIZE=2]"Blue"[/SIZE], Color.**[SIZE=2]BLUE[/SIZE]** );
  blue.setLocation( CLocation.**working**( workingArea ).rectangle( 0, 1, 1, 1 ) );
  workingArea.add(blue);
  blue.setVisible( **[SIZE=2]true[/SIZE]** );
  redBtn.setText([SIZE=2]""[/SIZE]);[/LEFT]
[/LEFT]

 

[LEFT]} **[SIZE=2]else[/SIZE]****[SIZE=2]if[/SIZE]**(text.equals(**[SIZE=2]INSERT_RED_DOCKABLE[/SIZE]**)) {
[LEFT]  DefaultSingleCDockable red = **[SIZE=2]new[/SIZE]** ColorSingleCDockable( [SIZE=2]"Red"[/SIZE], Color.**[SIZE=2]RED[/SIZE]** );
  red.setLocation( CLocation.**working**( workingArea ).rectangle( 0, 0, 1, 1 ) );
  workingArea.add(red);
  red.setVisible( **[SIZE=2]true[/SIZE]** );
  redBtn.setText(**[SIZE=2]INSERT_GREEN_DOCKABLE[/SIZE]**);
}[/LEFT]
[/LEFT]

 

[LEFT]}
[LEFT]});
frame.add(redBtn, BorderLayout.**[SIZE=2]WEST[/SIZE]**);[/LEFT]
[/LEFT]

 

[LEFT]frame.setVisible(**[SIZE=2]true[/SIZE]**);

}[/LEFT]

[LEFT]Thank you[/LEFT]

I wanted to write an example, but I realized there is a bug preventing my example from running. I have to fix that first, the answer will come a bit later. Sorry for that.

P.S. In the future could you please use the JAVA-tags of the forum to format your code. Your HTML converter produces code that cannot be compiled… thank you.

As soon as the upload for 1.1.0p6d finishes, the following code will work. Is this what you wanted? Or have I completely misunderstood your intention?


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import tutorial.support.ColorSingleCDockable;
import tutorial.support.JTutorialFrame;
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.location.AbstractStackholdingLocation;
import bibliothek.gui.dock.common.location.CStackLocation;

public class Dock40 {

	private static final String INSERT_GREEN_DOCKABLE = "Insert Green Dockable";
	private static final String INSERT_RED_DOCKABLE = "Insert Red Dockable";
	private static final String INSERT_BLUE_DOCKABLE = "Insert Blue Dockable";

	public static void main( String[] args ){
		JTutorialFrame frame = new JTutorialFrame( Dock40.class );
		CControl control = new CControl( frame );
		frame.destroyOnClose( control );
		final CWorkingArea workingArea = control.createWorkingArea( "workingarea" );
		frame.add( workingArea.getComponent(), BorderLayout.CENTER );

		final JButton redBtn = new JButton( INSERT_RED_DOCKABLE );
		redBtn.addActionListener( new ActionListener() {
			DefaultSingleCDockable green;
			DefaultSingleCDockable red;
			DefaultSingleCDockable blue;

			@Override
			public void actionPerformed( ActionEvent actionEvent ){
				String text = redBtn.getText();

				if (text.equals( INSERT_RED_DOCKABLE )) {
					red = new ColorSingleCDockable( "Red", Color.RED );
					red.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
					workingArea.add( red );
					red.setVisible( true );
					redBtn.setText( INSERT_GREEN_DOCKABLE );
				}
				else if (text.equals( INSERT_GREEN_DOCKABLE )) {
					green = new ColorSingleCDockable( "Green", Color.GREEN );
					green.setLocation( related( red.getBaseLocation(), workingArea, 1 ) );
					workingArea.add( green );
					green.setVisible( true );
					redBtn.setText( INSERT_BLUE_DOCKABLE );

				} else if (text.equals( INSERT_BLUE_DOCKABLE )) {
					blue = new ColorSingleCDockable( "Blue", Color.BLUE );
					blue.setLocation( related( green.getBaseLocation(), workingArea, 0 ) );
					workingArea.add( blue );
					blue.setVisible( true );
					redBtn.setText( "" );

				}
			}
		} );
		frame.add( redBtn, BorderLayout.WEST );

		frame.setVisible( true );
	}
	
	public static CLocation related( CLocation base, CWorkingArea area, int index ){
		if( base instanceof CStackLocation ){
			CLocation parent = base.getParent();
			return new CStackLocation( parent, index );
		}
		else if( base instanceof AbstractStackholdingLocation ){
			return ((AbstractStackholdingLocation)base).stack( index );
		}
		else{
			return base.aside();
		}
	}
}```

Hi,

Thank you Beni, This waht I want when inserting a new dockable.
Could you please give me an example how can I retrieve and delete a dockable from the WorkingArea by index

Thank you

Iterate over all Dockables that were ever created by the user and check their location. Something like this:

[Edit: wrong example, I’ll have to answer in the evening]

Thank you beni, waiting for your example.

It will be more easier, if I could have a method in the CWorkingArea or CGridArea that allows me to insertByIndex, removeByIndex, selectByDockable, etc… Like
JTabbedPane.[SIZE=2]insertTab(String title, Icon icon, Component component, String tip, [SIZE=2]int[/SIZE] index)
[/SIZE]JTabbedPane.[SIZE=2]removeTabAt([SIZE=2]int[/SIZE] index) [/SIZE]
[SIZE=2]JTabbedPane.[SIZE=2]getSelectedIndex()[/SIZE][/SIZE]
[SIZE=2][SIZE=2]JTabbedPane.[SIZE=2]setSelectedIndex()[/SIZE][/SIZE][/SIZE]

[SIZE=2][SIZE=2][SIZE=2]Thank you
[/SIZE][/SIZE][/SIZE]

My example is a bit too easy and you won’t be able to use it directly. Because the stations and dockables are organized in a tree, an index could only be useful to access a Dockable in respect to its direct parent.

The CWorkingArea can have the CDockables either directly as children, or it can have some StackDockStations with CDockables in it as children (or a wild mix). An index is just a bit too simple to describe these situations.

You can go to the Core framework, there the Dockables do have an index, but your application will have to provide some additional information to make things going right. Run the second example and you’ll see what I mean.

Example A: removing a Dockable identified by its index on its parent.
Example B: showing a layout where the index is ambiguous.

I’m not sure if that helps, but I still think there is some misunderstanding and you try to use a tree like a list.

Example A:


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import tutorial.support.ColorSingleCDockable;
import tutorial.support.JTutorialFrame;
import bibliothek.gui.DockStation;
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.layout.DockableProperty;
import bibliothek.gui.dock.station.stack.StackDockProperty;

public class Dock40 {
	public static void main( String[] args ){
		JTutorialFrame frame = new JTutorialFrame( Dock40.class );
		CControl control = new CControl( frame );
		frame.destroyOnClose( control );
		final CWorkingArea workingArea = control.createWorkingArea( "workingarea" );
		frame.add( workingArea.getComponent(), BorderLayout.CENTER );

		final DefaultSingleCDockable green;
		final DefaultSingleCDockable red;
		final DefaultSingleCDockable blue;

		red = new ColorSingleCDockable( "Red", Color.RED );
		red.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
		workingArea.add( red );
		red.setVisible( true );

		green = new ColorSingleCDockable( "Green", Color.GREEN );
		green.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
		workingArea.add( green );
		green.setVisible( true );

		blue = new ColorSingleCDockable( "Blue", Color.BLUE );
		blue.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
		workingArea.add( blue );
		blue.setVisible( true );
		
		JButton button = new JButton( "remove" );
		frame.add( button, BorderLayout.WEST );
		button.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e ){
				int index = 0;
				remove(index, red, green, blue);
			}
		});

		frame.setVisible( true );
	}


	public static void remove( int index, CDockable... check ){
		// This is the second version. Mind you: the parent of the dockables may *not*
		// be the CWorkingArea but a StackDockStation that is a child of the working-area.
		// This is because stations and dockables build a tree, not a list.
		for( CDockable dockable : check ){
			if( dockable.isVisible() ){
				CommonDockable intern = dockable.intern();
				DockStation parent = intern.getDockParent();
			
				for( int i = 0, n = parent.getDockableCount(); i<n; i++ ){
					if( parent.getDockable( i ) == intern ){
						dockable.setVisible( false );
						return;
					}
				}
			}
		}
		
		// this was the first version, but it will not cover all cases
//		for( CDockable dockable : check ){
//			if( dockable.isVisible() ){
//				CLocation location = dockable.getBaseLocation();
//				DockableProperty property = location.findProperty();
//				if( property instanceof StackDockProperty ){
//					if( ((StackDockProperty)property).getIndex() == index ){
//						dockable.setVisible( false );
//						return;
//					}
//				}
//				else if( index == 0 ){
//					dockable.setVisible( false );
//					return;
//				}
//			}
//		}
	}
}```





Example B:
```package test;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import tutorial.support.ColorSingleCDockable;
import tutorial.support.JTutorialFrame;
import bibliothek.gui.DockStation;
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.layout.DockableProperty;
import bibliothek.gui.dock.station.stack.StackDockProperty;

public class Dock40 {
	public static void main( String[] args ){
		JTutorialFrame frame = new JTutorialFrame( Dock40.class );
		CControl control = new CControl( frame );
		frame.destroyOnClose( control );
		final CWorkingArea workingArea = control.createWorkingArea( "workingarea" );
		frame.add( workingArea.getComponent(), BorderLayout.CENTER );

		final DefaultSingleCDockable green;
		final DefaultSingleCDockable red;
		final DefaultSingleCDockable blue;
		final DefaultSingleCDockable yellow;

		red = new ColorSingleCDockable( "Red", Color.RED );
		red.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
		workingArea.add( red );
		red.setVisible( true );

		green = new ColorSingleCDockable( "Green", Color.GREEN );
		green.setLocation( CLocation.working( workingArea ).rectangle( 0, 0, 1, 1 ) );
		workingArea.add( green );
		green.setVisible( true );

		blue = new ColorSingleCDockable( "Blue", Color.BLUE );
		blue.setLocation( CLocation.working( workingArea ).rectangle( 0, 0.5, 1, 0.5 ) );
		workingArea.add( blue );
		blue.setVisible( true );
		
		yellow = new ColorSingleCDockable( "Yellow", Color.YELLOW );
		yellow.setLocation( CLocation.working( workingArea ).rectangle( 0, 0.5, 1, 0.5 ) );
		workingArea.add( yellow );
		yellow.setVisible( true );
		
		JButton button = new JButton( "remove" );
		frame.add( button, BorderLayout.WEST );
		button.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e ){
				int index = 0;
				remove(index, red, green, blue, yellow);
			}
		});

		frame.setVisible( true );
	}


	public static void remove( int index, CDockable... check ){
		// This is the second version. Mind you: the parent of the dockables may *not*
		// be the CWorkingArea but a StackDockStation that is a child of the working-area.
		// This is because stations and dockables build a tree, not a list.
		for( CDockable dockable : check ){
			if( dockable.isVisible() ){
				CommonDockable intern = dockable.intern();
				DockStation parent = intern.getDockParent();
				
				for( int i = 0, n = parent.getDockableCount(); i<n; i++ ){
					if( parent.getDockable( i ) == intern ){
						dockable.setVisible( false );
						return;
					}
				}
			}
		}
		
	}
}```

Hi Beni,

Thank you so much for the examples

I can’t see any difference between example A and B, except that in example A you have added a commented method. So I assumed that the remove method of the example A should run the commented code. Advice me if I’m wrong please

As in the example B, you are not removing by index, the method remove took as paramater the dockable and you are always removing the first one. I expect to be able to call parentstation.removeDockableAt(dockablePosition).

For me a CWorkingArea is a parent and each dockable inside it , is a child of this CWorkingArea and I expect to be able to call workingArea.removeDockableAt(2) in order to remove the dockable at index 2.

The CWorkingArea can have the CDockables either directly as children, or it can have some StackDockStations with CDockables in it as children (or a wild mix). An index is just a bit too simple to describe these situations.

Regarding the above syntax, the CWorkingArea does’t know the index of each displayed dockable?
Can the CworkingArea get/add/remove/select dockable without looping on the dockable?

Thank you

As in the example B, you are not removing by index, the method remove took as paramater the dockable and you are always removing the first one. I expect to be able to call parentstation.removeDockableAt(dockablePosition).

The „index“ parameter is for that :slight_smile: Set it to 3 or 4, and the method will fail even tough there are 4 dockables.

For me a CWorkingArea is a parent and each dockable inside it , is a child of this CWorkingArea and I expect to be able to call workingArea.removeDockableAt(2) in order to remove the dockable at index 2.

Call the visit method (see code below) in either of the examples from my last post. You’ll notice that this statement is false, in these examples the CWorkingArea is not a parent of any CDockable. Instead it is the parent of one (or two) StackDockStations which in return are the parents of the CDockables.

Can the CworkingArea get/add/remove/select dockable without looping on the dockable?

No, the design of the framework assumes that you know the CDockable object you want to change, and thus offers methods like „setVisible“ or „toFront“ there.

If you need to search the object first, you will need to loop through the tree, like the code below (which only prints out the tree).

	private static void visit( CWorkingArea area ){
		visit( area.intern() );
	}
	
	private static void visit( Dockable dockable ){
		if( dockable.asDockStation() != null ){
			visit( dockable.asDockStation() );
		}
		else{
			System.out.println( "visit: " + dockable.getClass() );
		}
	}
	
	private static void visit( DockStation station ){
		System.out.println( "start: " + station.getClass() );
		
		for( int i = 0, n = station.getDockableCount(); i<n; i++ ){
			visit( station.getDockable( i ));
		}
		
		System.out.println( "end: " + station.getClass() );
	}```

Hi Beni,

It is clearer now. Thank you.

Questions:

  1. Do a CWorkingArea always contains a SplitDockStation which will contain a StackDockStation? Can I check on this condition?

  2. In the below method from Example A


[LEFT]**[SIZE=2]public [/SIZE]****[SIZE=2]static [/SIZE]****[SIZE=2]void[/SIZE]** remove(**[SIZE=2]int[/SIZE]** index, CDockable... check) {
[SIZE=2]  // this was the first version, but it will not cover all cases[/SIZE]
**[SIZE=2]  for[/SIZE]** (CDockable dockable : check) {
**[SIZE=2]  if[/SIZE]** (dockable.isVisible()) {
    CLocation location = dockable.getBaseLocation();
    DockableProperty property = location.findProperty();
**[SIZE=2]    if[/SIZE]** (property **[SIZE=2]instanceof[/SIZE]** StackDockProperty) {
**[SIZE=2]        if[/SIZE]** (((StackDockProperty) property).getIndex() == index) {
            dockable.setVisible(**[SIZE=2]false[/SIZE]**);
**[SIZE=2]            return[/SIZE]**;
        }
    } **[SIZE=2]else[/SIZE]****[SIZE=2]if[/SIZE]** (index == 0) {
       dockable.setVisible(**[SIZE=2]false[/SIZE]**);
**[SIZE=2]       return[/SIZE]**;
   }
 }
}[/LEFT]
}

The

CLocation location = dockable.getBaseLocation();

is returning [CStackLocation], but the


 
[LEFT]DockableProperty property = location.findProperty();[/LEFT]
 
 


[LEFT]is returning [SplitDockProperty]. Is it normal?[/LEFT]

[LEFT]Thank you[/LEFT]

That is correct. The CStackDockLocation points to some parent which then describes the working-area. And the SplitDockProperty points to the working-area but has a child that represents the stack. It’s the same, just seen from two different angles.

Interesting…

Could you please advice why I’m getting an exception when clicking on minimize or maximize

**[SIZE=2]
[LEFT]import**[/SIZE] java.awt.BorderLayout;[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] java.awt.Color;

?[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] bibliothek.gui.dock.common.CControl;[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] bibliothek.gui.dock.common.CLocation;[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] bibliothek.gui.dock.common.CWorkingArea;[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] bibliothek.gui.dock.common.DefaultSingleCDockable;
[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] tutorial.support.ColorSingleCDockable;[/LEFT]
**[SIZE=2][LEFT]import**[/SIZE] tutorial.support.JTutorialFrame;

?[/LEFT]
**[SIZE=2][LEFT]public**[/SIZE] **[SIZE=2]class**[/SIZE] Dock44 {
**[SIZE=2]public**[/SIZE] Dock44() {
}

?
**[SIZE=2]public**[/SIZE] **[SIZE=2]static**[/SIZE] **[SIZE=2]void**[/SIZE] main(String[] args) {
JTutorialFrame frame = **[SIZE=2]new**[/SIZE] JTutorialFrame(Dock44.**[SIZE=2]class**[/SIZE]);

CControl control = **[SIZE=2]new**[/SIZE] CControl(frame);
frame.destroyOnClose(control);
**[SIZE=2]final**[/SIZE] CWorkingArea workingArea = control.createWorkingArea([SIZE=2]"workingarea"[/SIZE]);
frame.add(workingArea.getComponent(), BorderLayout.**[SIZE=2]CENTER**[/SIZE]);
**[SIZE=2]final**[/SIZE] DefaultSingleCDockable green;
**[SIZE=2]final**[/SIZE] DefaultSingleCDockable red;
**[SIZE=2]final**[/SIZE] DefaultSingleCDockable blue;
red = **[SIZE=2]new**[/SIZE] ColorSingleCDockable([SIZE=2]"Red"[/SIZE], Color.**[SIZE=2]RED**[/SIZE]);
red.setLocation(CLocation.**working**(workingArea).rectangle(0, 0, 1, 1));
workingArea.add(red);
red.setVisible(**[SIZE=2]true**[/SIZE]);
green = **[SIZE=2]new**[/SIZE] ColorSingleCDockable([SIZE=2]"Green"[/SIZE], Color.**[SIZE=2]GREEN**[/SIZE]);
green.setLocation(CLocation.**working**(workingArea).rectangle(0, 0, 1, 1));
workingArea.add(green);
green.setVisible(**[SIZE=2]true**[/SIZE]);
blue = **[SIZE=2]new**[/SIZE] ColorSingleCDockable([SIZE=2]"Blue"[/SIZE], Color.**[SIZE=2]BLUE**[/SIZE]);
blue.setLocation(CLocation.**working**(workingArea).rectangle(0, 0, 1, 1));
workingArea.add(blue);
workingArea.getComponent().setBackground(Color.**[SIZE=2]ORANGE**[/SIZE]);
blue.setVisible(**[SIZE=2]true**[/SIZE]);
frame.setVisible(**[SIZE=2]true**[/SIZE]);
}[/LEFT]
}

Thank you

What exception?

But the answer is most likely: because you have only a working-area and the working-area alone does not support minimization or maximization. Usually an application creates a CContentArea (or uses the default CContentArea which can be accessed by CControl.getContentArea) and then puts a CWorkingArea into that CContentArea. The CContentArea then adds minimization and maximization capabilities to the application.

Hi,

If my root is a CWorkingArea, which contains 3 dockables and manually I moved those dockables from stack to split and then I clicked on the minize button of one dockable, I’m getting the below exception.

If in the above case I can’t minize a dockable, why I’m seeing the minimize button?

FYI In getting the following exception

[SIZE=2]
[LEFT]Exception in thread "AWT-EventQueue-0" [/SIZE][U][SIZE=2]java.lang.NullPointerException[/LEFT]
[/U][/SIZE][SIZE=2][LEFT]at bibliothek.gui.dock.facile.mode.DefaultLocationMode.runApply([/SIZE][U][SIZE=2]DefaultLocationMode.java:68[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply([/SIZE][U][SIZE=2]AbstractLocationMode.java:354[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply([/SIZE][U][SIZE=2]AbstractLocationMode.java:1[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager$4.run([/SIZE][U][SIZE=2]ModeManager.java:668[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:486[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:465[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.apply([/SIZE][U][SIZE=2]ModeManager.java:666[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.apply([/SIZE][U][SIZE=2]ModeManager.java:597[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.apply([/SIZE][U][SIZE=2]ModeManager.java:533[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.apply([/SIZE][U][SIZE=2]ModeManager.java:513[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.LocationModeManager$6$1.setMode([/SIZE][U][SIZE=2]LocationModeManager.java:287[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.common.group.SingleGroupMovement.apply([/SIZE][U][SIZE=2]SingleGroupMovement.java:52[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.LocationModeManager$6.run([/SIZE][U][SIZE=2]LocationModeManager.java:285[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager$3.run([/SIZE][U][SIZE=2]ModeManager.java:448[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:486[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:446[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:427[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.LocationModeManager.apply([/SIZE][U][SIZE=2]LocationModeManager.java:280[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.LocationModeManager$5.run([/SIZE][U][SIZE=2]LocationModeManager.java:256[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:486[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.support.mode.ModeManager.runTransaction([/SIZE][U][SIZE=2]ModeManager.java:465[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.facile.mode.LocationModeManager.setMode([/SIZE][U][SIZE=2]LocationModeManager.java:249[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.common.intern.AbstractCDockable.setExtendedMode([/SIZE][U][SIZE=2]AbstractCDockable.java:355[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.common.intern.action.CExtendedModeAction.action([/SIZE][U][SIZE=2]CExtendedModeAction.java:189[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.common.intern.action.CExtendedModeAction$Action.action([/SIZE][U][SIZE=2]CExtendedModeAction.java:220[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.themes.basic.action.BasicButtonHandler.triggered([/SIZE][U][SIZE=2]BasicButtonHandler.java:48[/U][/SIZE][SIZE=2])
at bibliothek.gui.dock.themes.basic.action.BasicButtonModel.trigger([/SIZE][U][SIZE=2]BasicButtonModel.java:631[/U][/SIZE][SIZE=2])[/LEFT]
at bibliothek.gui.dock.themes.basic.action.BasicButtonModel$Listener.mouseReleased([/SIZE][U][SIZE=2]BasicButtonModel.java:669[/U][/SIZE][SIZE=2])
[/SIZE]

Thank you

Because there is no code that would hide the button :slight_smile: , usually there always is a way to minimize the dockable hence I never bothered to catch this case. As a workaround, just call „setMinimizeable(false)“ and „setMaximizeable(false)“ to hide the buttons, I’ll add a better exception for the next release (not yet sure if I’m going to hide the buttons).

Thank you Beni.

I really need a component in the common project that ONLY allows STACKED dockables.
I’m having problems with the CWorkingArea because it allows stacked and splitte ddockables

Is it feasible to change in the CWorkingArea or to create a CStackedWorkingArea to be able to only allow stacked dockables?
It is really a must in my case

Thank you

It should not be hard to implement your own CStation that wrapps around a StackDockStation and offers this functionality. The StackDockStation from Core allows nothing but stacking, and CStation is only a small wrapper around it.

I’ll surely write some skeleton/example in the evening, currently I have my hands full with other stuff.