Hi,
I have a StackStation that contains 3 dockables. The three dockables have a title and an icon and all those dockables are closeable.
When I close a first dockable, the StackDockStation will contains 2 dockables with a title, icon and the close button
When I close the second, the last dockable lost its title and icon and I’m not able to close it
Could you please check if I’m doing something wrong?
public class Demo03_Theme {
public Demo03_Theme() {
// create a frame
JFrame frame = new JFrame("Demo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(600, 500);
DockController controller = new DockController();
controller.setTheme(new EclipseTheme());
controller.getProperties().set(EclipseTheme.PAINT_ICONS_WHEN_DESELECTED, true);
final StackDockStation station = new StackDockStation();
frame.add(station.getComponent(), BorderLayout.CENTER);
controller.add(station);
for (int i = 0; i < 3; i++) {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(new JButton("Button"));
panel.setOpaque(true);
DefaultDockable dockable = new DefaultDockable(panel, "Dockable " + i);
dockable.setTitleIcon(new ImageIcon(getClass().getClassLoader().getResource("demo/flap_south.png")));
station.drop(dockable);
CloseAction closeAction = new CloseAction(controller) {
@Override
protected void close(Dockable dockable) {
int dockableIndex = station.indexOf(dockable);
station.remove(dockableIndex);
station.getComponent().repaint();
}
};
// Creates a list of DockActions that contains a single action which is the closeAction
DefaultDockActionSource source = new DefaultDockActionSource(new LocationHint(LocationHint.DOCKABLE, LocationHint.LEFT), closeAction);
// Sets the below defined action to this Dockable
dockable.setActionOffers(source);
}
frame.setVisible(true);
}
public static void main(String[] args) {
new Demo03_Theme();
}
}
Thank you,