分享

如何使用Dockables

 liuzi02 2010-05-27
 如何使用Dockables

How to Use Dockables如何使用Dockables

:: A dockable for a UI component :: ::一个可停靠的UI组件::

如果你要添加一个用户界面功能对接组件,您必须创建一个可Dockable它。 您的组件作为内容的可停靠。

		// Create the content component.创建内容的组成部分。
TextPanel textPanel = new TextPanel("I am window 1.");
// Create the dockable around the content component.创建可停靠约的内容组成部分。
Dockable dockable = new DefaultDockable("Window1", textPanel, "Window", null, DockingMode.ALL);
 
在第一个参数的DefaultDockable是可停靠的ID。应用程序标识您所有的dockables中应有所不同。

 

:: A dockable with an icon and a description :: ::带有图标和描述可停靠::

你可以考虑到可停靠的图标和描述。图标将显示在停靠的是头码头,可停靠的地方。该说明将显示为工具提示头以上。

		// Create the dockable around the content component.创建可停靠约的内容组成部分
Icon icon = new ImageIcon(getClass().getResource("/com/javadocking/resources/images/text12.gif"));
DefaultDockable dockable = new DefaultDockable("Window1", textPanel, "Window", icon);
dockable.setDescription("Window with text");

:: Specifying the docks where a dockable can be docked :: ::指定其中一个可停靠的码头,可停靠::

您可以指定在什么样的停靠船坞可以通过设置模式对接对接。不同的对接模式是类定义在DockingMode

在下例中例如dockables不能自由浮动。

		// We don't want the dockables to float.我们不希望dockables浮动。
int dockingModes = DockingMode.ALL - DockingMode.FLOAT;
// Create the dockables around the content components.创建dockables围绕内容的组成部分。
Dockable dockable = new DefaultDockable("Window1", textPanel, "Window", icon, dockingModes);

:: A dockable with actions :: ::与行动停靠::

你可以装点一个使用一个可停靠的行动, ActionDockable 。首先,你必须创建您的基本可停靠。 然后你创建包装器周围可停靠停靠行动,这增加了它的行动。

在folowing例如可停靠第一次装饰结束行动。然后是行动与另外2个装饰。

		// Create the dockable around the content component./ /创建可停靠约的内容组成部分。
Dockable dockable = new DefaultDockable("Window1", textPanel, "Window", new ImageIcon("resources/images/text12.gif"));
// Decorate the dockable with a close action./ /装饰用紧密行动停靠。
dockable = new StateActionDockable(dockable, new DefaultDockableStateActionFactory(), DockableState.STATES_CLOSED);
// Decorate the dockable with another action./ /装饰与另一行动停靠
MessageAction helloAction = new MessageAction(this, "Hello", new ImageIcon("/com/javadocking/resources/images/hello12.gif"), "Hello world!");
MessageAction cautionAction = new MessageAction(this, "Caution", new ImageIcon("/com/javadocking/resources/images/caution12.gif"), "Be Careful!");
Action[][] actions = new Action[1][];
actions[0] = new Action[2];
actions[0][0] = helloAction;
actions[0][1] = cautionAction;
dockable = new ActionDockable(dockable, actions);

:: Dragging functionality on the content of the dockable :: ::拖动功能,对停靠内容::

一个可停靠总是可以拖拖头的码头,其中停靠。这也可以拖动其内容可停靠拖动。

 如果你想要那个,界面内容您可停靠应执行DraggableContent 。该接口包含一个方法addDragListener(DragListener)。 拖动侦听应该加入能够为鼠标拖动可停靠的听众和鼠标运动监听每个组件与您想要的。

A possible implementation is:一种可能的实现是:

		public void addDragListener(DragListener dragListener)
{
this.addMouseListener(dragListener);
this.addMouseMotionListener(dragListener);
label.addMouseListener(dragListener);
label.addMouseMotionListener(dragListener);
}


The source code of the samples can be found in:样品的源代码中可以找到:

SimpleDockable SimpleDockable Shows a simple dockable.显示了一个简单的可停靠。
IconDockable IconDockable Shows a dockable with an icon and tooltip.显示了一个图标和一个可停靠的工具提示。
NotFloatingDockable NotFloatingDockable Shows a dockable that cannot float.显示了一个可停靠的,不能自由浮动。
ActionsDockable ActionsDockable Shows a dockable with actions.以行动显示了可停靠。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多