Пример #1
0
  public FloatChildDocks(JFrame frame) {
    super(new BorderLayout());

    // Create the dock model for the docks.
    FloatDockModel dockModel = new FloatDockModel();
    dockModel.addOwner("frame0", frame);

    // Give the dock model to the docking manager.
    DockingManager.setDockModel(dockModel);

    // Create the content components.
    TextPanel textPanel1 = new TextPanel("I am window 1.");
    TextPanel textPanel2 = new TextPanel("I am window 2.");
    TextPanel textPanel3 = new TextPanel("I am window 3.");

    // Create the dockables around the content components.
    Icon icon =
        new ImageIcon(getClass().getResource("/com/javadocking/resources/images/text12.gif"));
    Dockable dockable1 = new DefaultDockable("Window1", textPanel1, "Window 1", icon);
    Dockable dockable2 = new DefaultDockable("Window2", textPanel2, "Window 2", icon);
    Dockable dockable3 = new DefaultDockable("Window3", textPanel3, "Window 3", icon);

    // Create the single child docks for the float dock.
    SingleDock singleDock1 = new SingleDock();
    SingleDock singleDock2 = new SingleDock();

    // Add the dockables to the single docks.
    singleDock1.addDockable(dockable1, SingleDock.SINGLE_POSITION);
    singleDock2.addDockable(dockable2, SingleDock.SINGLE_POSITION);

    // Create the tab dock.
    TabDock tabDock = new TabDock();

    // Add the dockable to the tab dock.
    tabDock.addDockable(dockable3, new Position(0));

    // The position for the float child docks.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = screenSize.width / 2 - 100;
    int y = screenSize.height / 2 - 100;

    // Get the float dock. This is a standard dock of the floating dock model.
    FloatDock floatDock = dockModel.getFloatDock(frame);
    floatDock.setChildDockFactory(new SingleDockFactory());
    floatDock.setDockPriority(Priority.CAN_DOCK_WITH_PRIORITY);

    // Add the child docks to the float dock.
    floatDock.addChildDock(singleDock1, new Position(x, y, 0));
    floatDock.addChildDock(singleDock2, new Position(x + 50, y + 50, 1));

    // Add the 1 root dock to the dock model.
    dockModel.addRootDock("tabDock", tabDock, frame);

    // Add the split pane to the panel.
    add(tabDock, BorderLayout.CENTER);
  }
Пример #2
0
  public VisualizersExample(JFrame frame) {
    super(new BorderLayout());

    // Create the dock model for the docks.
    FloatDockModel dockModel = new FloatDockModel();
    dockModel.addOwner("frame0", frame);

    // Give the dock model to the docking manager.
    DockingManager.setDockModel(dockModel);

    // Create the content components.
    TextPanel textPanel1 = new TextPanel("I am window 1.");
    TextPanel textPanel2 = new TextPanel("I am window 2.");
    TextPanel textPanel3 = new TextPanel("I am window 3.");
    TextPanel textPanel4 = new TextPanel("I am window 4.");
    TextPanel textPanel5 = new TextPanel("I am window 5.");
    TextPanel textPanel6 = new TextPanel("I am window 6.");
    TextPanel textPanel7 = new TextPanel("I am window 7.");
    TextPanel textPanel8 = new TextPanel("I am window 8.");
    TextPanel textPanel9 = new TextPanel("I am window 9.");

    // Create the dockables around the content components.
    Icon icon =
        new ImageIcon(getClass().getResource("/com/javadocking/resources/images/text12.gif"));
    Dockable dockable1 = new DefaultDockable("Window1", textPanel1, "Window 1", icon);
    Dockable dockable2 = new DefaultDockable("Window2", textPanel2, "Window 2", icon);
    Dockable dockable3 = new DefaultDockable("Window3", textPanel3, "Window 3", icon);
    Dockable dockable4 = new DefaultDockable("Window4", textPanel4, "Window 4", icon);
    Dockable dockable5 = new DefaultDockable("Window5", textPanel5, "Window 5", icon);
    Dockable dockable6 = new DefaultDockable("Window6", textPanel6, "Window 6", icon);
    Dockable dockable7 = new DefaultDockable("Window7", textPanel7, "Window 7", icon);
    Dockable dockable8 = new DefaultDockable("Window8", textPanel8, "Window 8", icon);
    Dockable dockable9 = new DefaultDockable("Window9", textPanel9, "Window 9", icon);

    // Add minimize, maximize, externalize, and close actions to the dockables.
    dockable1 = addActions(dockable1);
    dockable2 = addActions(dockable2);
    dockable3 = addActions(dockable3);
    dockable4 = addActions(dockable4);
    dockable5 = addActions(dockable5);
    dockable6 = addActions(dockable6);
    dockable7 = addActions(dockable7);
    dockable8 = addActions(dockable8);
    dockable9 = addActions(dockable9);

    // Create the child tab dock.
    TabDock leftTabDock = new TabDock();
    TabDock rightTabDock = new TabDock();

    // Add the dockables to the tab dock.
    leftTabDock.addDockable(dockable1, new Position(0));
    leftTabDock.addDockable(dockable2, new Position(1));
    rightTabDock.addDockable(dockable3, new Position(0));
    rightTabDock.addDockable(dockable4, new Position(1));

    // Create the split dock.
    SplitDock splitDock = new SplitDock();

    // Add the child docks to the split dock at the left and right.
    splitDock.addChildDock(leftTabDock, new Position(Position.LEFT));
    splitDock.addChildDock(rightTabDock, new Position(Position.RIGHT));
    splitDock.setDividerLocation(395);

    // Add the root dock to the dock model.
    dockModel.addRootDock("splitDock", splitDock, frame);

    // Create an externalizer.
    FloatExternalizer externalizer = new FloatExternalizer(frame);
    dockModel.addVisualizer("externalizer", externalizer, frame);

    // Create a minimizer.
    LineMinimizer minimizer = new LineMinimizer(splitDock);
    dockModel.addVisualizer("minimizer", minimizer, frame);

    // Create a maximizer.
    SingleMaximizer maximizer = new SingleMaximizer(minimizer);
    dockModel.addVisualizer("maximizer", maximizer, frame);

    // Add the maximizer to the panel.
    this.add(maximizer, BorderLayout.CENTER);

    // Minimize dockables.
    minimizer.visualizeDockable(dockable5);
    minimizer.visualizeDockable(dockable6);
    minimizer.visualizeDockable(dockable7);
    minimizer.visualizeDockable(dockable8);

    // Externalize dockable.
    // externalizer.visualizeDockable(dockable9);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Point location = new Point((screenSize.width - 200) / 2, (screenSize.height - 200) / 2);
    externalizer.externalizeDockable(dockable9, location);
  }