java类javax.swing.tree.TreeCellRenderer的实例源码

ResultTreeView.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
public Component getTreeCellRendererComponent(JTree tree,
                                                 Object value,
                                                 boolean selected,
                                                 boolean expanded,
                                                 boolean leaf,
                                                 int row,
                                                 boolean hasFocus) {
       boolean isResultRootNode =
                       (value instanceof TreeNode)
                       && (((TreeNode) value).getParent() == null);
// render no icon space an empty icon of a callStackFrame
       boolean isCallstackFrame = false;
       if (null != value) {
           isCallstackFrame = (Visualizer.findNode(value) instanceof CallstackFrameNode);
       }

       TreeCellRenderer renderer = (isResultRootNode || isCallstackFrame)
                                   ? noIconTreeCellRenderer
                                   : defaultTreeCellRenderer;
       return renderer.getTreeCellRendererComponent(
               tree, value, selected, expanded, leaf, row, hasFocus);
   }
FirstRowCellEditor.java 文件源码 项目:ramus 阅读 16 收藏 0 点赞 0 评论 0
public boolean isCellEditable(final EventObject anEvent) {
    if (anEvent instanceof MouseEvent) {
        final MouseEvent event = (MouseEvent) anEvent;
        final int row = treeTable.rowAtPoint(event.getPoint());
        final Rectangle bounds = tree.getRowBounds(row);
        int offset = bounds.x;
        final Object node = tree.getPathForRow(row).getLastPathComponent();
        final boolean leaf = tree.getModel().isLeaf(node);
        final boolean expanded = tree.isExpanded(row);
        final TreeCellRenderer tcr = tree.getCellRenderer();
        final Component treeComponent = tcr.getTreeCellRendererComponent(
                tree, node, true, expanded, leaf, row, false);
        if (treeComponent instanceof JLabel) {
            final JLabel label = (JLabel) treeComponent;

            final Icon icon = label.getIcon();
            if (icon != null) {
                offset += icon.getIconWidth() + label.getIconTextGap();
            }

        }
        if (event.getPoint().x < offset)
            return false;
    }
    return deligate.isCellEditable(anEvent);
}
JTreeTable.java 文件源码 项目:audiveris 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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"));
    }
}
TreeTableCellRenderer.java 文件源码 项目:checkstyle-backport-jre6 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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.
    final TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        final DefaultTreeCellRenderer renderer = (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.
        // renderer.setBorderSelectionColor(null);
        renderer.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        renderer.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
JTreeTable.java 文件源码 项目:spring16project-Modula-2 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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);
        // 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"));
        ((DefaultTreeCellRenderer)this.getCellRenderer()).setLeafIcon(null);
        ((DefaultTreeCellRenderer)this.getCellRenderer()).setOpenIcon(null);
        ((DefaultTreeCellRenderer)this.getCellRenderer()).setClosedIcon(null);
    }
}
TaskTable.java 文件源码 项目:spring16project-Modula-2 阅读 21 收藏 0 点赞 0 评论 0
/**
     * 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"));
        }
    }
DefectTable.java 文件源码 项目:spring16project-Modula-2 阅读 25 收藏 0 点赞 0 评论 0
/**
     * 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"));
        }
    }
JTreeTable.java 文件源码 项目:spring16project-Fortran 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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"));
        ((DefaultTreeCellRenderer) this.getCellRenderer()).setLeafIcon(null);
        ((DefaultTreeCellRenderer) this.getCellRenderer()).setOpenIcon(null);
        ((DefaultTreeCellRenderer) this.getCellRenderer()).setClosedIcon(null);
    }
}
TaskTable.java 文件源码 项目:spring16project-Fortran 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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"));
    }
}
BasicTreeUI.java 文件源码 项目:javify 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Sets the TreeCellRenderer to <code>tcr</code>. This invokes
 * <code>updateRenderer</code>.
 *
 * @param tcr is the new TreeCellRenderer.
 */
protected void setCellRenderer(TreeCellRenderer tcr)
{
  // Finish editing before changing the renderer.
  completeEditing();

  // The renderer is set in updateRenderer.
  updateRenderer();

  // Refresh the layout if necessary.
  if (treeState != null)
    {
      treeState.invalidateSizes();
      updateSize();
    }
}
BasicTreeUI.java 文件源码 项目:javify 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Paints the renderer part of a row. The receiver should NOT modify
 * clipBounds, or insets.
 *
 * @param g - the graphics configuration
 * @param clipBounds -
 * @param insets -
 * @param bounds - bounds of expand control
 * @param path - path to draw control for
 * @param row - row to draw control for
 * @param isExpanded - is the row expanded
 * @param hasBeenExpanded - has the row already been expanded
 * @param isLeaf - is the path a leaf
 */
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets,
                        Rectangle bounds, TreePath path, int row,
                        boolean isExpanded, boolean hasBeenExpanded,
                        boolean isLeaf)
{
  boolean selected = tree.isPathSelected(path);
  boolean hasIcons = false;
  Object node = path.getLastPathComponent();

  paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded,
                     hasBeenExpanded, isLeaf);

  TreeCellRenderer dtcr = currentCellRenderer;

  boolean focused = false;
  if (treeSelectionModel != null)
    focused = treeSelectionModel.getLeadSelectionRow() == row
              && tree.isFocusOwner();

  Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
                                                  isExpanded, isLeaf, row,
                                                  focused);

  rendererPane.paintComponent(g, c, c.getParent(), bounds);
}
TreeTableView.java 文件源码 项目:intellij-ce-playground 阅读 23 收藏 0 点赞 0 评论 0
public TreeTableView(ListTreeTableModelOnColumns treeTableModel) {
  super(treeTableModel);
  setRootVisible(false);

  setTreeCellRenderer(new TreeCellRenderer() {
    private final TreeCellRenderer myBaseRenderer = new HighlightableCellRenderer();
    public Component getTreeCellRendererComponent(JTree tree1,
                                                  Object value,
                                                  boolean selected,
                                                  boolean expanded,
                                                  boolean leaf,
                                                  int row,
                                                  boolean hasFocus) {
      JComponent result = (JComponent)myBaseRenderer.getTreeCellRendererComponent(tree1, value, selected, expanded, leaf, row, hasFocus);
      result.setOpaque(!selected);
      return result;
    }
  });

  setSizes();
}
TreeExpandableItemsHandler.java 文件源码 项目:intellij-ce-playground 阅读 16 收藏 0 点赞 0 评论 0
@Override
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
  int rowIndex = key.intValue();

  TreePath path = myComponent.getPathForRow(rowIndex);
  if (path == null) return null;

  Rectangle bounds = myComponent.getPathBounds(path);
  if (bounds == null) return null;

  TreeCellRenderer renderer = myComponent.getCellRenderer();
  if (renderer == null) return null;

  Object node = path.getLastPathComponent();
  Component rendererComponent = renderer.getTreeCellRendererComponent(
    myComponent,
    node,
    myComponent.isRowSelected(rowIndex),
    myComponent.isExpanded(rowIndex),
    myComponent.getModel().isLeaf(node),
    rowIndex,
    myComponent.hasFocus()
  );
  return Pair.create(rendererComponent, bounds);
}
BasicTreeUI.java 文件源码 项目:jvm-stm 阅读 21 收藏 0 点赞 0 评论 0
/**
  * Sets the TreeCellRenderer to <code>tcr</code>. This invokes
  * <code>updateRenderer</code>.
  * 
  * @param tcr is the new TreeCellRenderer.
  */
 protected void setCellRenderer(TreeCellRenderer tcr)
 {
   // Finish editing before changing the renderer.
   completeEditing();

   // The renderer is set in updateRenderer.
   updateRenderer();

   // Refresh the layout if necessary.
   if (treeState != null)
     {
treeState.invalidateSizes();
updateSize();
     }
 }
BasicTreeUI.java 文件源码 项目:jvm-stm 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Paints the renderer part of a row. The receiver should NOT modify
 * clipBounds, or insets.
 * 
 * @param g - the graphics configuration
 * @param clipBounds -
 * @param insets -
 * @param bounds - bounds of expand control
 * @param path - path to draw control for
 * @param row - row to draw control for
 * @param isExpanded - is the row expanded
 * @param hasBeenExpanded - has the row already been expanded
 * @param isLeaf - is the path a leaf
 */
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets,
                        Rectangle bounds, TreePath path, int row,
                        boolean isExpanded, boolean hasBeenExpanded,
                        boolean isLeaf)
{
  boolean selected = tree.isPathSelected(path);
  boolean hasIcons = false;
  Object node = path.getLastPathComponent();

  paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded,
                     hasBeenExpanded, isLeaf);

  TreeCellRenderer dtcr = currentCellRenderer;

  boolean focused = false;
  if (treeSelectionModel != null)
    focused = treeSelectionModel.getLeadSelectionRow() == row
              && tree.isFocusOwner();

  Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
                                                  isExpanded, isLeaf, row,
                                                  focused);

  rendererPane.paintComponent(g, c, c.getParent(), bounds);
}
JXTreeTable.java 文件源码 项目:swingx 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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"));
    }
}
TreeRolloverController.java 文件源码 项目:swingx 阅读 18 收藏 0 点赞 0 评论 0
@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
    TreeCellRenderer renderer = component.getCellRenderer();
    RolloverRenderer rollover = renderer instanceof RolloverRenderer 
        ? (RolloverRenderer) renderer : null;
    if ((rollover != null) && !rollover.isEnabled()) {
        rollover = null;
    }
    if ((rollover != null) && prepare) {
        TreePath path = component.getPathForRow(location.y);
        Object element = path != null ? path.getLastPathComponent() : null;
        renderer.getTreeCellRendererComponent(component, element, false, 
                false, false, 
                location.y, false);
    }
    return rollover;
}
TreeTableCellEditor.java 文件源码 项目:swingx 阅读 17 收藏 0 点赞 0 评论 0
/**
     * @param row
     * @param isSelected
     */
    protected void initEditorOffset(JTable table, int row, int column,
            boolean isSelected) {
        if (tree == null)
            return;
//        Rectangle bounds = tree.getRowBounds(row);
//        int offset = bounds.x;
        Object node = tree.getPathForRow(row).getLastPathComponent();
        boolean leaf = tree.getModel().isLeaf(node);
        boolean expanded = tree.isExpanded(row);
        TreeCellRenderer tcr = tree.getCellRenderer();
        Component editorComponent = tcr.getTreeCellRendererComponent(tree, node,
                isSelected, expanded, leaf, row, false);

        ((TreeTableTextField) getComponent()).init(row,
                column, table, tree, editorComponent);
    }
JXTreeUnitTest.java 文件源码 项目:swingx 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Issue #817-swingx: Delegating renderer must create list's default.
 * Delegating has default from list initially, here: custom default.
 */
@Test
public void testDelegatingRendererUseCustomDefaultSetNull() {
    JXTree list = new JXTree() {

        @Override
        protected TreeCellRenderer createDefaultCellRenderer() {
            return new CustomDefaultRenderer();
        }

    };
    TreeCellRenderer defaultRenderer = list.createDefaultCellRenderer();
    DelegatingRenderer renderer = (DelegatingRenderer) list.getCellRenderer();
    list.setCellRenderer(null);
    assertEquals("wrapping renderer must use list's default on null",
            defaultRenderer.getClass(), renderer.getDelegateRenderer().getClass());
}
JXTreeUnitTest.java 文件源码 项目:swingx 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Issue #817-swingx: Delegating renderer must create list's default.
 * Delegating has default from list initially, here: custom default.
 */
@Test
public void testDelegatingRendererUseCustomDefault() {
    JXTree list = new JXTree() {

        @Override
        protected TreeCellRenderer createDefaultCellRenderer() {
            return new CustomDefaultRenderer();
        }

    };
    TreeCellRenderer defaultRenderer = list.createDefaultCellRenderer();
    assertEquals("sanity: creates custom", CustomDefaultRenderer.class, 
            defaultRenderer.getClass());
    DelegatingRenderer renderer = (DelegatingRenderer) list.getCellRenderer();
    assertEquals(defaultRenderer.getClass(), renderer.getDelegateRenderer().getClass());
}
RendererVisualCheck.java 文件源码 项目:swingx 阅读 21 收藏 0 点赞 0 评论 0
/**
 * xtable/xlist using the same custom component controller.<p>
 * 
 */
public void interactiveTableAndTreeCustomColorRenderingController() {
    TableModel tableModel = new AncientSwingTeam();
    ComponentProvider<JLabel> controller = createColorRenderingLabelController();
    JXTable xtable = new JXTable(tableModel);
    xtable.setDefaultRenderer(Color.class, new DefaultTableRenderer(controller));
    TreeModel model = createTreeColorModel();
    JTree tree = new JTree(model);
    ComponentProvider<?> wrapper = new WrappingProvider(controller); //;createColorRenderingLabelController());
    TreeCellRenderer renderer = new DefaultTreeRenderer(wrapper);
    tree.setCellRenderer(renderer);
    JXFrame frame = wrapWithScrollingInFrame(xtable, tree, "JXTable/JXTree: Custom color renderer - sharing the component controller");
    addMessage(frame, "share provider in table and in wrappingProvider does not work?");
    frame.pack();
    frame.setVisible(true);
}
JXTreeTableVisualCheck.java 文件源码 项目:swingx 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Creates and returns a core default tree cell renderer with tooltip.
 * @return
 */
private TreeCellRenderer createTreeRenderer() {
    final TreeCellRenderer delegate = new DefaultTreeCellRenderer();
    TreeCellRenderer renderer = new TreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, 
                boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            Component result = delegate.getTreeCellRendererComponent(tree, value, 
                    selected, expanded, leaf, row, hasFocus);
            ((JComponent) result).setToolTipText(String.valueOf(tree.getPathForRow(row)));
             return result;
        }

    };
    return renderer;
}
JTreeTable.java 文件源码 项目:mindraider 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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);
        // 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"));
    }
}
JTreeTable.java 文件源码 项目:viewer 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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);
    // 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"));
    }
}
FileSelectionDialog.java 文件源码 项目:aTunes 阅读 23 收藏 0 点赞 0 评论 0
private void setTreeRenderer() {
    fileSystemTree.setCellRenderer(new TreeCellRenderer() {
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;

            if (node.getUserObject() instanceof String)
                return new JLabel();

            Directory content = (Directory) node.getUserObject();
            JLabel icon = new JLabel(value.toString());
            icon.setIcon(fsView.getSystemIcon(content.file));

            return icon;
        }
    });
}
JXTreeTable.java 文件源码 项目:aibench-project 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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"));
    }
}
TreeRolloverController.java 文件源码 项目:aibench-project 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
    TreeCellRenderer renderer = component.getCellRenderer();
    RolloverRenderer rollover = renderer instanceof RolloverRenderer 
        ? (RolloverRenderer) renderer : null;
    if ((rollover != null) && !rollover.isEnabled()) {
        rollover = null;
    }
    if ((rollover != null) && prepare) {
        TreePath path = component.getPathForRow(location.y);
        Object element = path != null ? path.getLastPathComponent() : null;
        renderer.getTreeCellRendererComponent(component, element, false, 
                false, false, 
                location.y, false);
    }
    return rollover;
}
JTreeTable.java 文件源码 项目:incubator-taverna-workbench 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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);
        // 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"));
    }
}
Jtv.java 文件源码 项目:jtv 阅读 20 收藏 0 点赞 0 评论 0
void handleNormalize(KeyEvent e){
    if( (e.getModifiers() & KeyEvent.CTRL_MASK) != 0 ){
        e.consume();
        resetSize();
    }else if( (e.getModifiers() & KeyEvent.ALT_MASK) != 0 ){

        TreeCellRenderer cellRenderer = tree.getCellRenderer();

        if( cellRenderer instanceof DefaultTreeCellRenderer ){

            e.consume();

            DefaultTreeCellRenderer dCellRenderer =
                (DefaultTreeCellRenderer) cellRenderer;

            Font font = dCellRenderer.getFont();
            Font next = new Font(font.getName(), font.getStyle(), 12);
            dCellRenderer.setFont( next );
            cmdInput.storeCaretPos();
            cmdInput.setFont( next );
            SwingUtilities.updateComponentTreeUI(topFrame);
            cmdInput.restoreCaretPos();
        }
    }
}
BasicTreeUI.java 文件源码 项目:cn1 阅读 26 收藏 0 点赞 0 评论 0
public void propertyChange(final PropertyChangeEvent e) {
    String changedProperty = e.getPropertyName();
    if (JTree.CELL_RENDERER_PROPERTY.equals(changedProperty)) {
        setCellRenderer((TreeCellRenderer)e.getNewValue());
    } else if (JTree.CELL_EDITOR_PROPERTY.equals(changedProperty)) {
        setCellEditor((TreeCellEditor)e.getNewValue());
    } else if (JTree.TREE_MODEL_PROPERTY.equals(changedProperty)) {
        setModel((TreeModel)e.getNewValue());
    } else if (JTree.ROOT_VISIBLE_PROPERTY.equals(changedProperty)) {
        setRootVisible(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SHOWS_ROOT_HANDLES_PROPERTY.equals(changedProperty)) {
        setShowsRootHandles(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.ROW_HEIGHT_PROPERTY.equals(changedProperty)) {
        setRowHeight(((Integer)e.getNewValue()).intValue());
    } else if (JTree.EDITABLE_PROPERTY.equals(changedProperty)) {
        setEditable(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.LARGE_MODEL_PROPERTY.equals(changedProperty)) {
        setLargeModel(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SELECTION_MODEL_PROPERTY.equals(changedProperty)) {
        setSelectionModel((TreeSelectionModel)e.getNewValue());
    } else if (JTree.LEAD_SELECTION_PATH_PROPERTY.equals(changedProperty)) {
        TreePath leadPath = (TreePath)e.getNewValue();
        lastSelectedRow = leadPath != null ? tree.getRowForPath(leadPath) : -1;
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号