本文整理汇总了Java中javax.swing.JTree.getDropLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.getDropLocation方法的具体用法?Java JTree.getDropLocation怎么用?Java JTree.getDropLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.getDropLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adaptContainerStyle
import javax.swing.JTree; //导入方法依赖的package包/类
private void adaptContainerStyle(JTree tree, Object node, boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus, boolean dragging, boolean setForeground) {
SwingTools.setEnabledRecursive(this, tree.isEnabled());
Color fg = null;
Color bg = null;
boolean highlightingEnabled = RapidMinerGUI.getDragHighlighteMode().equals(DragHighlightMode.FULL);
JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null && dropLocation.getChildIndex() == -1
&& tree.getRowForPath(dropLocation.getPath()) == row) {
fg = TEXT_SELECTED_COLOR;
bg = SELECTED_COLOR;
} else if (selected && !dragging) {
fg = TEXT_SELECTED_COLOR;
bg = SELECTED_COLOR;
} else {
fg = TEXT_NON_SELECTED_COLOR;
if (highlightingEnabled && dragging) {
bg = ProcessDrawer.INNER_DRAG_COLOR;
} else {
bg = NOT_SELECTED_COLOR;
}
}
if (setForeground) {
nameLabel.setForeground(fg);
attributeLabel.setForeground(fg);
}
this.setBackground(bg);
if (hasFocus) {
this.setBorder(focusBorder);
} else {
if (highlightingEnabled && dragging) {
this.setBorder(draggingNotFocusedBorder);
} else {
this.setBorder(nonFocusBorder);
}
}
}
示例2: getTreeCellRendererComponent
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Configures the renderer based on the passed in components.
* The value is set from messaging the tree with
* <code>convertValueToText</code>, which ultimately invokes
* <code>toString</code> on <code>value</code>.
* The foreground color is set based on the selection and the icon
* is set based on the <code>leaf</code> and <code>expanded</code>
* parameters.
*/
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean sel,
boolean expanded,
boolean leaf, int row,
boolean hasFocus) {
String stringValue = tree.convertValueToText(value, sel,
expanded, leaf, row, hasFocus);
this.tree = tree;
this.hasFocus = hasFocus;
setText(stringValue);
Color fg = null;
isDropCell = false;
JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null
&& dropLocation.getChildIndex() == -1
&& tree.getRowForPath(dropLocation.getPath()) == row) {
Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
if (col != null) {
fg = col;
} else {
fg = getTextSelectionColor();
}
isDropCell = true;
} else if (sel) {
fg = getTextSelectionColor();
} else {
fg = getTextNonSelectionColor();
}
setForeground(fg);
Icon icon = null;
if (leaf) {
icon = getLeafIcon();
} else if (expanded) {
icon = getOpenIcon();
} else {
icon = getClosedIcon();
}
if (!tree.isEnabled()) {
setEnabled(false);
LookAndFeel laf = UIManager.getLookAndFeel();
Icon disabledIcon = laf.getDisabledIcon(tree, icon);
if (disabledIcon != null) icon = disabledIcon;
setDisabledIcon(icon);
} else {
setEnabled(true);
setIcon(icon);
}
setComponentOrientation(tree.getComponentOrientation());
selected = sel;
return this;
}