本文整理汇总了Java中com.trollworks.toolkit.ui.menu.file.CloseHandler类的典型用法代码示例。如果您正苦于以下问题:Java CloseHandler类的具体用法?Java CloseHandler怎么用?Java CloseHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloseHandler类属于com.trollworks.toolkit.ui.menu.file包,在下文中一共展示了CloseHandler类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DockTab
import com.trollworks.toolkit.ui.menu.file.CloseHandler; //导入依赖的package包/类
/**
* Creates a new {@link DockTab} for the specified {@link Dockable}.
*
* @param dockable The {@link Dockable} to work with.
*/
public DockTab(Dockable dockable) {
super(new PrecisionLayout().setMargins(2, 4, 2, 4).setMiddleVerticalAlignment());
mDockable = dockable;
setOpaque(false);
setBorder(new EmptyBorder(2, 1, 0, 1));
addContainerListener(this);
mTitle = new JLabel(getFullTitle(), dockable.getTitleIcon(), SwingConstants.LEFT);
IconButton closeButton = new IconButton(StdImage.DOCK_CLOSE, CLOSE_TOOLTIP, this::attemptClose);
add(mTitle, new PrecisionLayoutData().setGrabHorizontalSpace(true).setHeightHint(Math.max(mTitle.getPreferredSize().height, closeButton.getPreferredSize().height)));
if (dockable instanceof CloseHandler) {
add(closeButton, new PrecisionLayoutData().setEndHorizontalAlignment());
}
if (dockable instanceof Saveable) {
((Saveable) dockable).addDataModifiedListener(this);
}
addMouseListener(this);
setToolTipText(dockable.getTitleTooltip());
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
}
示例2: attemptClose
import com.trollworks.toolkit.ui.menu.file.CloseHandler; //导入依赖的package包/类
/**
* Attempt to close a {@link Dockable} within this {@link DockContainer}. This only has an
* affect if the {@link Dockable} is contained by this {@link DockContainer} and implements the
* {@link CloseHandler} interface. Note that the {@link CloseHandler} must call this
* {@link DockContainer}'s {@link #close(Dockable)} method to actually close the tab.
*/
public void attemptClose(Dockable dockable) {
if (dockable instanceof CloseHandler) {
if (mDockables.contains(dockable)) {
CloseHandler closeable = (CloseHandler) dockable;
if (closeable.mayAttemptClose()) {
closeable.attemptClose();
}
}
}
}