/** * @return The icon color (same as component text by default) */ public Color getForeground() { if (foreground == null) return component.getForeground(); else return foreground; }
public static void adjustForegroundColorOnMouseover(final JComponent l, int amount) { final Color originalColor = l.getForeground(); final Color newColor = new Color(Math.min(originalColor.getRed() + amount, 255), Math.min(originalColor.getBlue() + amount, 255), Math.min(originalColor.getGreen() + amount, 255)); adjustForegroundColorOnMouseover(l, newColor); }
private void setForeground(final JComponent label, final Color color) { if(!this.colors.containsKey(label)) { this.colors.put(label, label.getForeground()); } label.setForeground(color); }
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { g.setColor(c.getForeground()); track = NapkinUtil.paintLine(g, vertical, track, trackBounds); }
private void setForeground(final JComponent comp, final Color color) { if(!this.colors.containsKey(comp)) { this.colors.put(comp, comp.getForeground()); } comp.setForeground(color); }
/** Paints the specified component */ public void paint(Graphics g, JComponent c) { Dimension s= c.getSize(); g.setColor(c.getBackground()); g.drawLine(0, 0, s.width, 0); g.setColor(c.getForeground()); g.drawLine(6, 0, s.width-10, 0); }
@Override public void mouseEntered( MouseEvent event ) { backupColor = ( ( JComponent ) event.getSource() ).getForeground(); if ( SetUp.getUsingBackgroundPicOfInformationFrame() ) { ( ( JComponent ) event.getSource() ).setForeground( Color.GREEN ); } } }
public static HTMLEditorKit buildHTMLEditorKit(JComponent component) { Objects.requireNonNull(component); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet ss = kit.getStyleSheet(); ss.addRule("body {font-family:sans-serif;font-size:12pt;background-color:#" //$NON-NLS-1$ + Integer.toHexString((component.getBackground().getRGB() & 0xffffff) | 0x1000000).substring(1) + ";color:#" //$NON-NLS-1$ + Integer.toHexString((component.getForeground().getRGB() & 0xffffff) | 0x1000000).substring(1) + ";margin:3;font-weight:normal;}"); //$NON-NLS-1$ return kit; }
private void highlightSuggestion(JComponent suggestion) { for (JComponent toClearHighlight : suggestionComponents) { removeHighlightSuggestion(toClearHighlight); } suggestion.setBorder(BorderFactory.createLineBorder(suggestion.getForeground())); suggestionScrollPane.scrollRectToVisible(suggestion.getBounds()); }
/** * Returns the foreground color of the renderered component or null if the * component is null * <p> * * PENDING: fallback to UI properties if comp == null? * * @return the foreground color of the rendered component. */ protected Color getForeground() { return getComponent() != null ? getComponent().getForeground() : null; }
@Override protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumb == null) { thumb = new DrawnBoxHolder(); } thumb.shapeUpToDate(thumbBounds); Graphics2D lineG = NapkinUtil.copy(g); lineG.setColor(c.getForeground()); lineG.translate(thumbBounds.x, thumbBounds.y); thumb.draw(lineG); }
/** * <p>Makes a Swing component inverted by swapping its foreground * and background colors. Hint: Depending on your needs it might * also be a good idea to call <tt>c.setOpaque(true)</tt>.</p> */ public static void invert(JComponent c) { Color invBackground = c.getForeground(); Color invForeground = c.getBackground(); c.setBackground(invBackground); c.setForeground(invForeground); } }
/** * <p>Makes a Swing component inverted by swapping its foreground * and background colors. Hint: Depending on your needs it might * also be a good idea to call <tt>c.setOpaque(true)</tt>.</p> */ public static void invert(JComponent c) { Color invBackground = c.getForeground(); Color invForeground = c.getBackground(); c.setBackground(invBackground); c.setForeground(invForeground); } }
/** * <p>Makes a Swing component inverted by swapping its foreground * and background colors. Hint: Depending on your needs it might * also be a good idea to call <tt>c.setOpaque(true)</tt>.</p> */ public static void invert(JComponent c) { Color invBackground = c.getForeground(); Color invForeground = c.getBackground(); c.setBackground(invBackground); c.setForeground(invForeground); } }
private Paint calculateStrokePaint(Object component, int width, int height) { Paint p = getBorderPaint(); if (p == null) { if(component instanceof JComponent) { p = ((JComponent)component).getForeground(); } } if(isPaintStretched()) { p = calculateSnappedPaint(p, width, height); } return p; }
public void setEmbed(JComponent _embed) { embed_=_embed; if(embed_!=null) { setForeground(embed_.getForeground()); setBackground(embed_.getBackground()); Dimension ps=embed_.getPreferredSize(); setWidth(ps.width); setHeight(ps.height); } }
/** * Apply the opacity, background color, foreground color and border properties of {@code source} to * {@code destination}. * @param source The source component. * @param destination The destination component. */ public static void copyComponentStyle(JComponent source, JComponent destination) { destination.setOpaque(source.isOpaque()); destination.setBackground(source.getBackground()); destination.setForeground(source.getForeground()); destination.setBorder(source.getBorder()); }
/** * Apply the opacity, background color, foreground color and border properties of {@code source} to * {@code destination}. * @param source The source component. * @param destination The destination component. */ public static void copyComponentStyle(JComponent source, JComponent destination) { destination.setOpaque(source.isOpaque()); destination.setBackground(source.getBackground()); destination.setForeground(source.getForeground()); destination.setBorder(source.getBorder()); }
public static void blinkComponent(JComponent component){ final Timeline timeline = new Timeline(component); timeline.addPropertyToInterpolate("background", component.getBackground(), GuiUtils.getAverageColor(component.getBackground(), component.getForeground())); timeline.setDuration(150); timeline.playLoop(2, Timeline.RepeatBehavior.REVERSE); } }
protected void copySettings( JComponent from, JComponent to ) { to.setForeground( from.getForeground( ) ); to.setBackground( from.getBackground( ) ); to.setEnabled( from.isEnabled( ) ); to.setFont( from.getFont( ) ); to.setOpaque( from.isOpaque( ) ); }