Add border for dockable component : Dockable « Swing Components « Java






Add border for dockable component

Add border for dockable component
package net.eleritec.docking.demos.border;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;

import net.eleritec.docking.DockingPort;
import net.eleritec.docking.defaults.ComponentProviderAdapter;
import net.eleritec.docking.defaults.DefaultDockingPort;

public class BorderDemo extends JFrame {
  
  public BorderDemo() {
    super("Border Docking Demo");
    setContentPane(createContentPane());
  }
  
  private JPanel createContentPane() {
    JPanel p = new JPanel(new BorderLayout(5, 5));
    p.add(buildDockingPort("North"), BorderLayout.NORTH);
    p.add(buildDockingPort("South"), BorderLayout.SOUTH);
    p.add(buildDockingPort("East"), BorderLayout.EAST);
    p.add(buildDockingPort("West"), BorderLayout.WEST);
    p.add(createDockingPort(), BorderLayout.CENTER);
    return p;
  }
  
  private DefaultDockingPort buildDockingPort(String desc) {
    // create the DockingPort
    DefaultDockingPort port = createDockingPort();

    // create the Dockable panel
    DockablePanel panel = new DockablePanel(desc);

    // dock the panel and return the DockingPort
    port.dock(panel.getDockable(), DockingPort.CENTER_REGION);
    return port;
  }
  
  private DefaultDockingPort createDockingPort() {
    DefaultDockingPort port = new DefaultDockingPort();
    port.setPreferredSize(new Dimension(100, 100));
    port.setBorderManager(new DemoBorderManager());
    port.setComponentProvider(new ComponentProvider());
    return port;
  }

  private class ComponentProvider extends ComponentProviderAdapter {
    public DockingPort createChildPort() {
      DefaultDockingPort port = new DefaultDockingPort();
      port.setComponentProvider(this);
      return port;
    }
    public JSplitPane createSplitPane() {
      JSplitPane split = new JSplitPane();
      split.setDividerSize(3);
      split.setBorder(null);
      if (split.getUI() instanceof BasicSplitPaneUI) {
        BasicSplitPaneDivider divider = ((BasicSplitPaneUI) split.getUI()).getDivider();
        if (divider != null && divider.getBorder()!=null)
          divider.setBorder(null);      
      }
      return split;
    }
  }



  public static void main(String[] args) {
    JFrame f = new BorderDemo();
    f.setSize(600, 400);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
}


           
       








dockingSrc-0.3.zip( 57 k)

Related examples in the same category

1.Swing dockable windowSwing dockable window
2.Simple demo for dockable windowsSimple demo for dockable windows
3.Compound dockable windowCompound dockable window
4.Cursor indication for dockable componentCursor indication for dockable component
5.SplitPane and dockable componentSplitPane and dockable component
6.Elegant Dockable frameworkElegant Dockable framework
7.TabbedPane and dockable component 2TabbedPane and dockable component 2
8.Swing dock framework