Changing External windows close button action

Hello,
I am working on a swing application where i want to not be able to close the external window manually by the user.
Example:
the window has to be docked to the top of the page and the user cannot close the windows application that is running. Is this possible using this docking framework ? I know we can modify the behavior of the internal windows but i need to know about the external ones.

I would appreciate a quick reply. thanks.

I am not certain what exactly you want to do. But in general you can prevent the user from executing certain drag-n-drop actions. Do you mean something like this?


import javax.swing.JFrame;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;

public class CLoseTest {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(20, 20, 400, 400);
		CControl control = new CControl(frame);
		frame.add(control.getContentArea());
		
		DefaultSingleCDockable dockable = createTestDockable();
		control.addDockable(dockable);
		dockable.setLocation(CLocation.external(50, 50, 300, 200));
		dockable.setVisible(true);
		
		frame.setVisible(true);
	}
	
	private static DefaultSingleCDockable createTestDockable(){
		DefaultSingleCDockable dockable = new DefaultSingleCDockable("id", "Title"){
			@Override
			public boolean isNormalizeable() {
				return false; // usually clients do not do this, hence this property cannot be set easily
			}
		};
		dockable.setMinimizable(false);
		return dockable;
	}
}

[QUOTE=Beni]I am not certain what exactly you want to do. But in general you can prevent the user from executing certain drag-n-drop actions. Do you mean something like this?


import javax.swing.JFrame;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;

public class CLoseTest {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(20, 20, 400, 400);
		CControl control = new CControl(frame);
		frame.add(control.getContentArea());
		
		DefaultSingleCDockable dockable = createTestDockable();
		control.addDockable(dockable);
		dockable.setLocation(CLocation.external(50, 50, 300, 200));
		dockable.setVisible(true);
		
		frame.setVisible(true);
	}
	
	private static DefaultSingleCDockable createTestDockable(){
		DefaultSingleCDockable dockable = new DefaultSingleCDockable("id", "Title"){
			@Override
			public boolean isNormalizeable() {
				return false; // usually clients do not do this, hence this property cannot be set easily
			}
		};
		dockable.setMinimizable(false);
		return dockable;
	}
}
```[/QUOTE]

thanks a lot for this informative reply. that does help. 
As a followup, is there a way to dock the main window to the top of the screen like a start menu is docked to the bottom of the screen ? I would like it so i dont have to resize the other windows that are running. they get resized just like when we drag the start toolbar to the top of the screen.

Once again I have no clue how exactly you would like to have your application showing up. But maybe something like this?


import javax.swing.JFrame;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;

public class CLoseTest {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(20, 20, 400, 400);
		CControl control = new CControl(frame);
		frame.add(control.getContentArea());
		
		DefaultSingleCDockable d1 = new DefaultSingleCDockable( "id1", "title 1" );
		DefaultSingleCDockable d2 = new DefaultSingleCDockable( "id2", "title 2" );
		DefaultSingleCDockable d3 = new DefaultSingleCDockable( "id3", "title 3" );
		DefaultSingleCDockable d4 = new DefaultSingleCDockable( "id4", "title 4" );
		
		control.addDockable(d1);
		control.addDockable(d2);
		control.addDockable(d3);
		control.addDockable(d4);
		
		d1.setLocation(CLocation.base().minimalNorth());
		d1.setVisible(true);

		d2.setLocationsAside(d1);
		d2.setVisible(true);
		
		d3.setLocation( CLocation.base().minimalNorth(1) );
		d3.setVisible( true );
		
		d4.setLocation( CLocation.base().normal() );
		d4.setVisible( true );
		
		frame.setVisible(true);
	}
}