Simple demo for dockable windows : Dockable « Swing Components « Java






Simple demo for dockable windows

Simple demo for dockable windows
package net.eleritec.docking.demos;

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

import javax.swing.JFrame;
import javax.swing.JPanel;

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

public class SimpleDemo extends JFrame {
  public static void main(String[] args) {
    JFrame f = new SimpleDemo();
    f.setSize(600, 400);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
  
  public SimpleDemo() {
    super("Simple Docking Demo");
    setContentPane(createContentPane());
  }
  
  private JPanel createContentPane() {
    JPanel p = new JPanel(new BorderLayout(5, 5));
    p.add(buildDockingPort(Color.blue, "Blue"), BorderLayout.NORTH);
    p.add(buildDockingPort(Color.red, "Red"), BorderLayout.SOUTH);
    p.add(buildDockingPort(Color.green, "Green"), BorderLayout.EAST);
    p.add(buildDockingPort(Color.yellow, "Yellow"), BorderLayout.WEST);
    p.add(createDockingPort(), BorderLayout.CENTER);
    return p;
  }
  
  private DefaultDockingPort buildDockingPort(Color color, String desc) {
    // create the DockingPort
    DefaultDockingPort port = createDockingPort();
    
    // create and register the Dockable panel
    JPanel p = new JPanel();
    p.setBackground(color);
    DockingManager.registerDockable(p, desc, true);
     
    // dock the panel and return the DockingPort
    port.dock(p, desc, DockingPort.CENTER_REGION, false);
    return port;
  }
  
  private DefaultDockingPort createDockingPort() {
    DefaultDockingPort port = new DefaultDockingPort();
    port.setBackground(Color.gray);
    port.setPreferredSize(new Dimension(100, 100));
    return port;
  }
}


           
       








dockingSrc-0.3.zip( 57 k)

Related examples in the same category

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