Hey Beni. I’m hoping you can help with this one I ran into this week. Basically, consider a button exists on a dockable that launches a modal popup. If the dockable is not externalized, the modal popup is open, and a user clicks on the dockable the input is ignored because of the modality. However, externalize that same dockable. Then launch the popup. Click behind the popup on the dockable and it will come forward, obscuring the modal popup if they are at the same location. If the dockable is larger than the popup, your application is now locked awaiting input on a modal dialog that cannot be accessed.
Check out the example below to see this in action. To see the bug, tear off dockable 2. Then click the LAUNCH POPUP button on the dockable. This was tested with java 6 and 7 on RHEL 6 with DockingFrames Preview Version 1.1.2 17b.
{
public Test3()
{
super();
setMinimumSize(new Dimension(500,500));
CControl control = new CControl(this);
add(control.getContentArea(), BorderLayout.CENTER);
control.setGroupBehavior(new TopMostGroupBehavior());
control.putProperty(StackDockStation.TAB_PLACEMENT,
TabPlacement.TOP_OF_DOCKABLE);
CPerspective layout =
control.getPerspectives().createEmptyPerspective();
CGridPerspective center = layout.getContentArea().getCenter();
Path path = new Path("custom", "flightlist");
center.gridPlaceholder(0, 0, 1, 1, path);
control.getPerspectives().setPerspective(layout, true);
PlaceholderGrouping group = new PlaceholderGrouping(control, path);
JPanel panel1 = new JPanel();
DefaultSingleCDockable dockable =
new DefaultSingleCDockable("1", null, "1", panel1, null);
CLocation location;
if (control.getCDockableCount() > 0)
{
location =
control.getCDockable(control.getCDockableCount() -
1).getBaseLocation();
}
else
{
location = control.getDefaultLocation();
}
dockable.setCloseable(false);
dockable.setMaximizable(false);
dockable.setMinimizable(false);
dockable.setTitleShown(false);
dockable.setGrouping(group);
dockable.setSingleTabShown(true);
dockable.setLocation(location);
control.addDockable(dockable);
dockable.setVisible(true);
JPanel panel2 = new JPanel();
JButton button = new JButton("LAUNCH POPUP");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent actionEvent)
{
Window parentWindow = (Window)SwingUtilities.getRoot((JButton)actionEvent.getSource());
JDialog popup = new JDialog(parentWindow, Dialog.ModalityType.APPLICATION_MODAL);
popup.setMinimumSize(new Dimension(200,200));
popup.pack();
popup.setLocationRelativeTo(parentWindow);
popup.setVisible(true);
}
});
panel2.add(button);
DefaultSingleCDockable dockable2 =
new DefaultSingleCDockable("2", null, "2", panel2, null);
CLocation location2;
if (control.getCDockableCount() > 0)
{
location2 =
control.getCDockable(control.getCDockableCount() -
1).getBaseLocation();
}
else
{
location2 = control.getDefaultLocation();
}
dockable2.setCloseable(false);
dockable2.setMaximizable(false);
dockable2.setMinimizable(false);
dockable2.setTitleShown(false);
dockable2.setGrouping(group);
dockable2.setSingleTabShown(true);
dockable2.setLocation(location2);
control.addDockable(dockable2);
dockable2.setVisible(true);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
pack();
setVisible(true);
}
});
}
public static void main(String[] args)
{
new Test3();
}
}```
Thanks for your help!