3 import java.awt.Component;
5 import javax.swing.JSplitPane;
6 import javax.swing.SwingUtilities;
9 * Class to control the showing and hiding of the sidebars
10 * (left panel, right panel and profile display)
12 public class SidebarController
14 /** array of hideable components */
15 private Component[] _components = null;
16 /** array of splitter panes */
17 private JSplitPane[] _splitters = null;
18 /** array of splitter positions */
19 private int[] _positions = null;
24 * @param inComponents array of components to hide/show
25 * @param inSplitters array of splitter panes
27 public SidebarController(Component[] inComponents, JSplitPane[] inSplitters)
29 _components = inComponents;
30 _splitters = inSplitters;
31 _positions = new int[inSplitters.length];
35 * Toggle full screen mode on or off
39 if (_components != null && _components.length > 0)
41 boolean visible = _components[0].isVisible();
43 // Store divider locations
44 for (int i=0; i<_components.length; i++) {
45 _positions[i] = _splitters[i].getDividerLocation();
48 // Set visibility of components
49 for (int i=0; i<_components.length; i++) {
50 _components[i].setVisible(!visible);
52 // Restore divider locations
53 for (int i=0; i<_components.length; i++) {
55 _splitters[i].setDividerLocation(_positions[i]);
58 // Hiding of panels has to occur in separate thread to update properly
59 if (visible) SwingUtilities.invokeLater(new Runnable() {
61 for (int i=0; i<_components.length; i++) {
62 _splitters[i].setDividerLocation(i==0?0.0:1.0);
63 _splitters[i].invalidate();