/** * Returns the shared ColumnHeaderRenderer. <p> * @return the shared header renderer. * */ public static TableCellRenderer getSharedInstance() { if (sharedInstance == null) { sharedInstance = new ColumnHeaderRenderer(); } return sharedInstance; }
private Component configureDelegate(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { Component comp = delegateRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex); applyLabelProperties(comp); return comp; }
public void setDownIcon(Icon icon) { Icon old = getDownIcon(); this.downIcon = icon; firePropertyChange("downIcon", old, getDownIcon()); }
public void setUpIcon(Icon icon) { Icon old = getUpIcon(); this.upIcon = icon; firePropertyChange("upIcon", old, getUpIcon()); }
@Override public void setBackground(Color background) { // this is called somewhere along initialization of super? if (label != null) { Color old = getBackground(); label.setBackground(background); firePropertyChange("background", old, getBackground()); } }
private void updateIconUI() { if (getUpIcon() instanceof UIResource) { Icon icon = UIManager.getIcon(UP_ICON_KEY); setUpIcon(icon != null ? icon : defaultUpIcon); } if (getDownIcon() instanceof UIResource) { Icon icon = UIManager.getIcon(DOWN_ICON_KEY); setDownIcon(icon != null ? icon : defaultDownIcon); } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { Component comp = configureDelegate(table, value, isSelected, hasFocus, rowIndex, columnIndex); if ((table instanceof JXTable) && (comp instanceof JComponent)) { // work-around core issues hackBorder((JComponent) comp); SortOrder sortOrder = ((JXTable) table).getSortOrder(columnIndex); // Border border = UIManager.getBorder("TableHeader.cellBorder"); // LOG.info("in renderer: " + UIManager.getBorder("TableHeader.cellBorder")); if (sortOrder.isSorted()) { iconBorder.setIcon(sortOrder.isAscending() ? upIcon : downIcon); Border origBorder = ((JComponent) comp).getBorder(); Border border = new CompoundBorder(origBorder, iconBorder); ((JComponent) comp).setBorder(border); } } adjustComponentOrientation(comp); return comp; }
public void setIcon(Icon icon) { Icon old = getIcon(); label.setIcon(icon); firePropertyChange("icon", old, getIcon()); }
public void setIconTextGap(int iconTextGap) { int old = getIconTextGap(); label.setIconTextGap(iconTextGap); firePropertyChange("iconTextGap", old, getIconTextGap()); }
@Override public void setFont(Font font) { if (label != null) { Font old = getFont(); label.setFont(font); firePropertyChange("font", old, getFont()); } }
@Override public void setForeground(Color foreground) { if (label != null) { Color old = getForeground(); label.setForeground(foreground); firePropertyChange("foreground", old, getForeground()); } }
public void setVerticalAlignment(int alignment) { int old = getVerticalAlignment(); label.setVerticalAlignment(alignment); firePropertyChange("verticalAlignment", old, getVerticalAlignment()); }
public void setVerticalTextPosition(int textPosition) { int old = getVerticalTextPosition(); label.setVerticalTextPosition(textPosition); firePropertyChange("verticalTextPosition", old, getVerticalTextPosition()); }
public void setHorizontalAlignment(int alignment) { int old = getHorizontalAlignment(); label.setHorizontalAlignment(alignment); firePropertyChange("horizontalAlignment", old, getHorizontalAlignment()); }
public void setHorizontalTextPosition(int textPosition) { int old = getHorizontalTextPosition(); label.setHorizontalTextPosition(textPosition); firePropertyChange("horizontalTextPosition", old, getHorizontalTextPosition()); }
/** * Cleans up after the UIDelegate has updated the default renderer. * Called from <code>updateUI</code> after calling <code>super.updateUI</code>. * This implementation wraps a <code>UIResource</code> default renderer into a * <code>ColumnHeaderRenderer</code>. * * @param oldRenderer the default renderer before updateUI * * @see #updateUI() * * */ protected void postUpdateRendererUI(TableCellRenderer oldRenderer) { TableCellRenderer current = getDefaultRenderer(); if (!(current instanceof ColumnHeaderRenderer) && (current instanceof UIResource)) { ColumnHeaderRenderer renderer; if (oldRenderer instanceof ColumnHeaderRenderer) { renderer = (ColumnHeaderRenderer) oldRenderer; renderer.updateUI(this); } else { renderer = new ColumnHeaderRenderer(this); } setDefaultRenderer(renderer); } }
/** * Adjusts the Component's orientation to JXTable's CO if appropriate. * Here: always. * * @param stamp the component to adjust. */ protected void adjustComponentOrientation(Component stamp) { if (stamp.getComponentOrientation().equals(getComponentOrientation())) return; stamp.applyComponentOrientation(getComponentOrientation()); }
/** * Prepares the default renderer and internal state for updateUI. * Returns the default renderer set when entering this method. * Called from updateUI before calling super.updateUI to * allow UIDelegate to cleanup, if necessary. This implementation * does so by restoring the header's default renderer to the * <code>ColumnHeaderRenderer</code>'s delegate. * * @return the current default renderer * @see #updateUI() */ protected TableCellRenderer preUpdateRendererUI() { TableCellRenderer oldRenderer = getDefaultRenderer(); // reset the default to the original to give S if (oldRenderer instanceof ColumnHeaderRenderer) { setDefaultRenderer(((ColumnHeaderRenderer)oldRenderer).getDelegateRenderer()); } return oldRenderer; }
/** * * @return a <code>ColumnHeaderRenderer</code> */ public static ColumnHeaderRenderer createColumnHeaderRenderer() { return new ColumnHeaderRenderer(); }