Border border = new CompoundBorder(textField.getBorder(), new IconBorder(...)); textField.setBorder( border );
/** * {@inheritDoc} */ public Insets getBorderInsets(Component c) { int horizontalInset = icon.getIconWidth() + (2 * padding); int iconPosition = bidiDecodeLeadingTrailing(c.getComponentOrientation(), this.iconPosition); if (iconPosition == SwingConstants.EAST) { return new Insets(0, 0, 0, horizontalInset); } return new Insets(0, horizontalInset, 0, 0); }
/** * Sets the position to place the icon (relative to the component contents). * * @param iconPosition must be one of the following {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. */ public void setIconPosition(int iconPosition) { if (!isValidPosition(iconPosition)) { throw new IllegalArgumentException("Invalid icon position"); } this.iconPosition = iconPosition; }
/** * Creates an {@code IconBorder} with the specified constraints. If * {@code validIcon} is {@code null}, {@code EMPTY_ICON} is used instead. * If {@code padding} is negative, then the border does not use padding. * * @param validIcon * the icon to set. This may be {@code null} to represent an * empty icon. * @param iconPosition * the position to place the icon relative to the component * contents. This must be one of the following * {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @param padding * the padding to surround the icon with. All non-positive values * set the padding to 0. * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. * @see #EMPTY_ICON */ public IconBorder(Icon validIcon, int iconPosition, int padding) { setIcon(validIcon); setPadding(padding); setIconPosition(iconPosition); }
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; }
/** * Creates an {@code IconBorder} with the specified constraints. If * {@code validIcon} is {@code null}, {@code EMPTY_ICON} is used instead. * If {@code padding} is negative, then the border does not use padding. * * @param validIcon * the icon to set. This may be {@code null} to represent an * empty icon. * @param iconPosition * the position to place the icon relative to the component * contents. This must be one of the following * {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @param padding * the padding to surround the icon with. All non-positive values * set the padding to 0. * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. * @see #EMPTY_ICON */ public IconBorder(Icon validIcon, int iconPosition, int padding) { setIcon(validIcon); setPadding(padding); setIconPosition(iconPosition); }
/** * Creates an {@code IconBorder} with the specified constraints. If * {@code validIcon} is {@code null}, {@code EMPTY_ICON} is used instead. * If {@code padding} is negative, then the border does not use padding. * * @param validIcon * the icon to set. This may be {@code null} to represent an * empty icon. * @param iconPosition * the position to place the icon relative to the component * contents. This must be one of the following * {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @param padding * the padding to surround the icon with. All non-positive values * set the padding to 0. * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. * @see #EMPTY_ICON */ public IconBorder(Icon validIcon, int iconPosition, int padding) { setIcon(validIcon); setPadding(padding); setIconPosition(iconPosition); }
private Border getTitleBorder() { if (monthView.isTraversable()) { IconBorder up = new IconBorder(monthUpImage, SwingConstants.EAST, monthView.getBoxPaddingX()); IconBorder down = new IconBorder(monthDownImage, SwingConstants.WEST, monthView.getBoxPaddingX()); Border compound = BorderFactory.createCompoundBorder(up, down); Border empty = BorderFactory .createEmptyBorder(2 * monthView.getBoxPaddingY(), 0, 2 * monthView.getBoxPaddingY(), 0); return BorderFactory.createCompoundBorder(compound, empty); } return BorderFactory.createEmptyBorder(monthView.getBoxPaddingY(), monthView.getBoxPaddingX(), monthView.getBoxPaddingY(), monthView.getBoxPaddingX()); } }
/** * {@inheritDoc} */ public Insets getBorderInsets(Component c) { int horizontalInset = icon.getIconWidth() + (2 * padding); int iconPosition = bidiDecodeLeadingTrailing(c.getComponentOrientation(), this.iconPosition); if (iconPosition == SwingConstants.EAST) { return new Insets(0, 0, 0, horizontalInset); } return new Insets(0, horizontalInset, 0, 0); }
/** * Sets the position to place the icon (relative to the component contents). * * @param iconPosition must be one of the following {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. */ public void setIconPosition(int iconPosition) { if (!isValidPosition(iconPosition)) { throw new IllegalArgumentException("Invalid icon position"); } this.iconPosition = iconPosition; }
/** * Creates an {@code IconBorder} with the specified constraints. If * {@code validIcon} is {@code null}, {@code EMPTY_ICON} is used instead. * If {@code padding} is negative, then the border does not use padding. * * @param validIcon * the icon to set. This may be {@code null} to represent an * empty icon. * @param iconPosition * the position to place the icon relative to the component * contents. This must be one of the following * {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @param padding * the padding to surround the icon with. All non-positive values * set the padding to 0. * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. * @see #EMPTY_ICON */ public IconBorder(Icon validIcon, int iconPosition, int padding) { setIcon(validIcon); setPadding(padding); setIconPosition(iconPosition); }
/** * @return */ private Border getTitleBorder() { if (getComponent().isTraversable()) { Icon downIcon = UIManager.getIcon("JXMonthView.monthDownFileName"); Icon upIcon = UIManager.getIcon("JXMonthView.monthUpFileName"); // fix for #1028-swingx: title border whacky for boxpadding 0 // in fact there had been a deeper issue - without using the arrowPadding here // the hit-detection of the buttons is slightly off target IconBorder up = new IconBorder(upIcon, SwingConstants.EAST, arrowPaddingX); IconBorder down = new IconBorder(downIcon, SwingConstants.WEST, arrowPaddingX); Border compound = BorderFactory.createCompoundBorder(up, down); Border empty = BorderFactory.createEmptyBorder(2* arrowPaddingY, 0, 2*arrowPaddingY, 0); return BorderFactory.createCompoundBorder(compound, empty); } return BorderFactory.createEmptyBorder(getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX(), getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX()); }
/** * {@inheritDoc} */ public Insets getBorderInsets(Component c) { int horizontalInset = icon.getIconWidth() + (2 * padding); int iconPosition = bidiDecodeLeadingTrailing(c.getComponentOrientation(), this.iconPosition); if (iconPosition == SwingConstants.EAST) { return new Insets(0, 0, 0, horizontalInset); } return new Insets(0, horizontalInset, 0, 0); }
/** * Sets the position to place the icon (relative to the component contents). * * @param iconPosition must be one of the following {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. */ public void setIconPosition(int iconPosition) { if (!isValidPosition(iconPosition)) { throw new IllegalArgumentException("Invalid icon position"); } this.iconPosition = iconPosition; }
/** * Creates an {@code IconBorder} with the specified constraints. If * {@code validIcon} is {@code null}, {@code EMPTY_ICON} is used instead. * If {@code padding} is negative, then the border does not use padding. * * @param validIcon * the icon to set. This may be {@code null} to represent an * empty icon. * @param iconPosition * the position to place the icon relative to the component * contents. This must be one of the following * {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @param padding * the padding to surround the icon with. All non-positive values * set the padding to 0. * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. * @see #EMPTY_ICON */ public IconBorder(Icon validIcon, int iconPosition, int padding) { setIcon(validIcon); setPadding(padding); setIconPosition(iconPosition); }
/** * @return */ private Border getTitleBorder() { if (getComponent().isTraversable()) { Icon downIcon = UIManager.getIcon("JXMonthView.monthDownFileName"); Icon upIcon = UIManager.getIcon("JXMonthView.monthUpFileName"); // fix for #1028-swingx: title border whacky for boxpadding 0 // in fact there had been a deeper issue - without using the arrowPadding here // the hit-detection of the buttons is slightly off target IconBorder up = new IconBorder(upIcon, SwingConstants.EAST, arrowPaddingX); IconBorder down = new IconBorder(downIcon, SwingConstants.WEST, arrowPaddingX); Border compound = BorderFactory.createCompoundBorder(up, down); Border empty = BorderFactory.createEmptyBorder(2* arrowPaddingY, 0, 2*arrowPaddingY, 0); return BorderFactory.createCompoundBorder(compound, empty); } return BorderFactory.createEmptyBorder(getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX(), getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX()); }
/** * {@inheritDoc} */ public Insets getBorderInsets(Component c) { int horizontalInset = icon.getIconWidth() + (2 * padding); int iconPosition = bidiDecodeLeadingTrailing(c.getComponentOrientation(), this.iconPosition); if (iconPosition == SwingConstants.EAST) { return new Insets(0, 0, 0, horizontalInset); } return new Insets(0, horizontalInset, 0, 0); }
/** * Sets the position to place the icon (relative to the component contents). * * @param iconPosition must be one of the following {@code SwingConstants}: * <ul> * <li>{@code LEADING}</li> * <li>{@code TRAILING}</li> * <li>{@code EAST}</li> * <li>{@code WEST}</li> * </ul> * @throws IllegalArgumentException * if {@code iconPosition} is not a valid position. */ public void setIconPosition(int iconPosition) { if (!isValidPosition(iconPosition)) { throw new IllegalArgumentException("Invalid icon position"); } this.iconPosition = iconPosition; }
/** * @return */ private Border getTitleBorder() { if (getComponent().isTraversable()) { Icon downIcon = UIManager.getIcon("JXMonthView.monthDownFileName"); Icon upIcon = UIManager.getIcon("JXMonthView.monthUpFileName"); // fix for #1028-swingx: title border whacky for boxpadding 0 // in fact there had been a deeper issue - without using the arrowPadding here // the hit-detection of the buttons is slightly off target IconBorder up = new IconBorder(upIcon, SwingConstants.EAST, arrowPaddingX); IconBorder down = new IconBorder(downIcon, SwingConstants.WEST, arrowPaddingX); Border compound = BorderFactory.createCompoundBorder(up, down); Border empty = BorderFactory.createEmptyBorder(2* arrowPaddingY, 0, 2*arrowPaddingY, 0); return BorderFactory.createCompoundBorder(compound, empty); } return BorderFactory.createEmptyBorder(getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX(), getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX()); }
/** * {@inheritDoc} */ public Insets getBorderInsets(Component c) { int horizontalInset = icon.getIconWidth() + (2 * padding); int iconPosition = bidiDecodeLeadingTrailing(c.getComponentOrientation(), this.iconPosition); if (iconPosition == SwingConstants.EAST) { return new Insets(0, 0, 0, horizontalInset); } return new Insets(0, horizontalInset, 0, 0); }