本文整理匯總了Java中javax.swing.tree.DefaultTreeCellRenderer.setBorderSelectionColor方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTreeCellRenderer.setBorderSelectionColor方法的具體用法?Java DefaultTreeCellRenderer.setBorderSelectionColor怎麽用?Java DefaultTreeCellRenderer.setBorderSelectionColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.DefaultTreeCellRenderer
的用法示例。
在下文中一共展示了DefaultTreeCellRenderer.setBorderSelectionColor方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateUI
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
* updateUI is overridden to set the colors of the Tree's renderer to
* match that of the table.
*/
@Override
public void updateUI ()
{
super.updateUI();
// Make the tree's cell renderer use the table's cell selection
// colors.
TreeCellRenderer tcr = getCellRenderer();
if (tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
// For 1.1 uncomment this, 1.2 has a bug that will cause an
// exception to be thrown if the border selection color is
// null.
dtcr.setBorderSelectionColor(null);
dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
}
}
示例2: updateUI
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
* updateUI is overridden to set the colors of the Tree's renderer to
* match that of the table.
*/
public void updateUI() {
super.updateUI();
// Make the tree's cell renderer use the table's cell selection
// colors.
TreeCellRenderer tcr = getCellRenderer();
if (tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
dtcr.setBorderSelectionColor(null);
dtcr.setTextSelectionColor(UIManager
.getColor("Table.selectionForeground"));
dtcr.setBackgroundSelectionColor(UIManager
.getColor("Table.selectionBackground"));
}
}
示例3: updateUI
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
* updateUI is overridden to set the colors of the Tree's renderer to
* match that of the table.
*/
@Override
public void updateUI() {
super.updateUI();
// Make the tree's cell renderer use the table's cell selection
// colors.
TreeCellRenderer tcr = getCellRenderer();
if (tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
dtcr.setBorderSelectionColor(null);
dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
}
}
示例4: updateUI
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
* updateUI is overridden to set the colors of the Tree's renderer
* to match that of the table.
*/
@Override
public void updateUI() {
super.updateUI();
// Make the tree's cell renderer use the table's cell selection
// colors.
// TODO JW: need to revisit...
// a) the "real" of a JXTree is always wrapped into a DelegatingRenderer
// consequently the if-block never executes
// b) even if it does it probably (?) should not
// unconditionally overwrite custom selection colors.
// Check for UIResources instead.
TreeCellRenderer tcr = getCellRenderer();
if (tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
// For 1.1 uncomment this, 1.2 has a bug that will cause an
// exception to be thrown if the border selection color is null.
dtcr.setBorderSelectionColor(null);
dtcr.setTextSelectionColor(
UIManager.getColor("Table.selectionForeground"));
dtcr.setBackgroundSelectionColor(
UIManager.getColor("Table.selectionBackground"));
}
}
示例5: paintRow
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
private void paintRow(TreeCellRenderer renderer,
DefaultTreeCellRenderer dtcr, SynthContext treeContext,
SynthContext cellContext, Graphics g, Rectangle clipBounds,
Insets insets, Rectangle bounds, Rectangle rowBounds,
TreePath path, int row, boolean isExpanded,
boolean hasBeenExpanded, boolean isLeaf) {
// Don't paint the renderer if editing this row.
boolean selected = tree.isRowSelected(row);
JTree.DropLocation dropLocation = tree.getDropLocation();
boolean isDrop = dropLocation != null
&& dropLocation.getChildIndex() == -1
&& path == dropLocation.getPath();
int state = ENABLED;
if (selected || isDrop) {
state |= SELECTED;
}
if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
state |= FOCUSED;
}
cellContext.setComponentState(state);
if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
UIResource)) {
dtcr.setBorderSelectionColor(style.getColor(
cellContext, ColorType.FOCUS));
}
SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
cellContext.getPainter().paintTreeCellBackground(cellContext, g,
rowBounds.x, rowBounds.y, rowBounds.width,
rowBounds.height);
cellContext.getPainter().paintTreeCellBorder(cellContext, g,
rowBounds.x, rowBounds.y, rowBounds.width,
rowBounds.height);
if (editingComponent != null && editingRow == row) {
return;
}
int leadIndex;
if (tree.hasFocus()) {
leadIndex = getLeadSelectionRow();
}
else {
leadIndex = -1;
}
Component component = renderer.getTreeCellRendererComponent(
tree, path.getLastPathComponent(),
selected, isExpanded, isLeaf, row,
(leadIndex == row));
rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
bounds.width, bounds.height, true);
}
示例6: paintRow
import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
private void paintRow(TreeCellRenderer renderer, DefaultTreeCellRenderer dtcr, SeaGlassContext treeContext, SeaGlassContext cellContext,
Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, Rectangle rowBounds, TreePath path, int row, boolean isExpanded,
boolean hasBeenExpanded, boolean isLeaf) {
// Don't paint the renderer if editing this row.
boolean selected = tree.isRowSelected(row);
JTree.DropLocation dropLocation = tree.getDropLocation();
boolean isDrop = dropLocation != null && dropLocation.getChildIndex() == -1 && path == dropLocation.getPath();
int state = ENABLED;
if (selected || isDrop) {
state |= SELECTED;
}
if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
state |= FOCUSED;
}
cellContext.setComponentState(state);
if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof UIResource)) {
dtcr.setBorderSelectionColor(style.getColor(cellContext, ColorType.FOCUS));
}
SeaGlassLookAndFeel.updateSubregion(cellContext, g, rowBounds);
cellContext.getPainter().paintTreeCellBackground(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
cellContext.getPainter().paintTreeCellBorder(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
if (editingComponent != null && editingRow == row) {
return;
}
int leadIndex;
if (tree.hasFocus()) {
leadIndex = getLeadSelectionRow();
} else {
leadIndex = -1;
}
Component component = renderer.getTreeCellRendererComponent(tree, path.getLastPathComponent(), selected, isExpanded, isLeaf, row,
(leadIndex == row));
rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y, bounds.width, bounds.height, true);
}