use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthStyle method installDefaults.
void installDefaults(SynthContext context, SynthUI ui) {
// can have more control over this.
if (!context.isSubregion()) {
JComponent c = context.getComponent();
Border border = c.getBorder();
if (border == null || border instanceof UIResource) {
c.setBorder(new SynthBorder(ui, getInsets(context, null)));
}
}
installDefaults(context);
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class AquaButtonLabeledUI method setThemeBorder.
protected void setThemeBorder(final AbstractButton b) {
super.setThemeBorder(b);
Border border = b.getBorder();
if (border == null || border instanceof UIResource) {
// Set the correct border
b.setBorder(AquaButtonBorder.getBevelButtonBorder());
}
}
use of javax.swing.plaf.UIResource in project android by JetBrains.
the class SimpleTabUI method paintText.
// Appears to be based on http://stackoverflow.com/questions/7903657/basictabbedpaneui-paint-html-text
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
g.setFont(font);
View v = getTextViewForTab(tabIndex);
if (v != null) {
// html
v.paint(g, textRect);
} else {
// plain text
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
Color fg = tabPane.getForegroundAt(tabIndex);
if (isSelected && (fg instanceof UIResource)) {
// CHANGE FROM DEFAULT
Color selectedFG = JBColor.BLUE;
if (selectedFG != null) {
fg = selectedFG;
}
}
g.setColor(fg);
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
} else {
// tab disabled
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
}
}
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthStyle method uninstallDefaults.
/**
* Uninstalls any state that this style installed on
* the <code>JComponent</code> from <code>context</code>.
* <p>
* Styles should NOT depend upon this being called, in certain cases
* it may never be called.
*
* @param context SynthContext identifying component to install properties
* to.
*/
public void uninstallDefaults(SynthContext context) {
if (!context.isSubregion()) {
// NOTE: because getForeground, getBackground and getFont will look
// at the parent Container, if we set them to null it may
// mean we they return a non-null and non-UIResource value
// preventing install from correctly settings its colors/font. For
// this reason we do not uninstall the fg/bg/font.
JComponent c = context.getComponent();
Border border = c.getBorder();
if (border instanceof UIResource) {
c.setBorder(null);
}
}
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthStyle method getColor.
/**
* Returns the color for the specified state. This gives precedence to
* foreground and background of the <code>JComponent</code>. If the
* <code>Color</code> from the <code>JComponent</code> is not appropriate,
* or not used, this will invoke <code>getColorForState</code>. Subclasses
* should generally not have to override this, instead override
* {@link #getColorForState}.
*
* @param context SynthContext identifying requester
* @param type Type of color being requested.
* @return Color
*/
public Color getColor(SynthContext context, ColorType type) {
JComponent c = context.getComponent();
Region id = context.getRegion();
if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
//text when the label is disabled. This code allows for that.
if (c instanceof JTextComponent) {
JTextComponent txt = (JTextComponent) c;
Color disabledColor = txt.getDisabledTextColor();
if (disabledColor == null || disabledColor instanceof UIResource) {
return getColorForState(context, type);
}
} else if (c instanceof JLabel && (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND)) {
return getColorForState(context, type);
}
}
// If the developer has specified a color, prefer it. Otherwise, get
// the color for the state.
Color color = null;
if (!id.isSubregion()) {
if (type == ColorType.BACKGROUND) {
color = c.getBackground();
} else if (type == ColorType.FOREGROUND) {
color = c.getForeground();
} else if (type == ColorType.TEXT_FOREGROUND) {
color = c.getForeground();
}
}
if (color == null || color instanceof UIResource) {
// Then use what we've locally defined
color = getColorForState(context, type);
}
if (color == null) {
// No color, fallback to that of the widget.
if (type == ColorType.BACKGROUND || type == ColorType.TEXT_BACKGROUND) {
return c.getBackground();
} else if (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND) {
return c.getForeground();
}
}
return color;
}
Aggregations