本文整理汇总了Java中javax.swing.plaf.synth.SynthStyle类的典型用法代码示例。如果您正苦于以下问题:Java SynthStyle类的具体用法?Java SynthStyle怎么用?Java SynthStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SynthStyle类属于javax.swing.plaf.synth包,在下文中一共展示了SynthStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColor
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
public Color getColor () {
SynthStyle style = getSynthStyle (aRegion);
if (Boolean.TRUE.equals(functioning)) {
try {
Color result = (Color) synthStyle_getColorForState.invoke (style,
new Object [] {
getSynthContext (),
aColorType
});
if (result == null) {
result = (Color) fallback;
}
if (darken) {
result = result.darker();
}
return result;
} catch (Exception e) {
functioning = Boolean.FALSE;
if (log) {
e.printStackTrace();
}
}
}
//This will only happen once, after which functioning will be false
return null;
}
示例2: fixGtkPopupStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private static void fixGtkPopupStyle() {
if (!UIUtil.isUnderGTKLookAndFeel()) return;
final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();
SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
@Override
public SynthStyle getStyle(final JComponent c, final Region id) {
final SynthStyle style = original.getStyle(c, id);
if (id == Region.POPUP_MENU) {
final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
if (x != null && x == 0) {
// workaround for Sun bug #6636964
ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
}
}
return style;
}
});
new JBPopupMenu(); // invokes updateUI() -> updateStyle()
SynthLookAndFeel.setStyleFactory(original);
}
示例3: patchGtkDefaults
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private static void patchGtkDefaults(UIDefaults defaults) {
if (!UIUtil.isUnderGTKLookAndFeel()) return;
Map<String, Icon> map = ContainerUtil.newHashMap(
Arrays.asList("OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"),
Arrays.asList(AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog));
// GTK+ L&F keeps icons hidden in style
SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
for (String key : map.keySet()) {
if (defaults.get(key) != null) continue;
Object icon = style == null ? null : style.get(null, key);
defaults.put(key, icon instanceof Icon ? icon : map.get(key));
}
Color fg = defaults.getColor("Label.foreground");
Color bg = defaults.getColor("Label.background");
if (fg != null && bg != null) {
defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
}
}
示例4: update
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* A convenience method that handles painting of the background. All SynthUI
* implementations should override update and invoke this method.
*
* @param context must not be null
* @param g must not be null
* @param the bounds to fill, may be null to indicate the complete size
*/
public static void update(SynthContext context, Graphics g, Rectangle bounds) {
JComponent c = context.getComponent();
SynthStyle style = context.getStyle();
int x, y, width, height;
if (bounds == null) {
x = 0;
y = 0;
width = c.getWidth();
height = c.getHeight();
} else {
x = bounds.x;
y = bounds.y;
width = bounds.width;
height = bounds.height;
}
// Fill in the background, if necessary.
boolean subregion = context.getRegion().isSubregion();
if ((subregion && style.isOpaque(context))
|| (!subregion && c.isOpaque())) {
g.setColor(style.getColor(context, ColorType.BACKGROUND));
g.fillRect(x, y, width, height);
}
}
示例5: initialize
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* Called by UIManager when this look and feel is installed.
*/
@Override
public void initialize() {
super.initialize();
// create synth style factory
setStyleFactory(new SynthStyleFactory() {
@Override
public SynthStyle getStyle(JComponent c, Region r) {
SynthStyle style = getSeaGlassStyle(c, r);
if (!(style instanceof SeaGlassStyle)) {
style = new SeaGlassStyleWrapper(style);
}
return style;
}
});
}
示例6: updateSeaglassStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* A convience method that will reset the Style of StyleContext if
* necessary.
*
* @return newStyle
*/
public static SynthStyle updateSeaglassStyle(SynthContext context, SeaglassUI ui) {
SynthStyle newStyle = getStyle(context.getComponent(), context.getRegion());
// TODO rossi 04.07.2011 this code is now private in the Synth L&F
// SynthStyle oldStyle = context.getStyle();
//
// if (newStyle != oldStyle) {
// if (oldStyle != null) {
// oldStyle.uninstallDefaults(context);
// }
// context.setStyle(newStyle);
// newStyle.installDefaults(context, ui);
// }
return newStyle;
}
示例7: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* A convience method that will reset the Style of StyleContext if
* necessary.
*
* @param context the SynthContext corresponding to the current state.
* @param ui the UI delegate.
*
* @return the new, updated style.
*/
public static SynthStyle updateStyle(SeaGlassContext context, SeaglassUI ui) {
SynthStyle newStyle = SynthLookAndFeel.getStyle(context.getComponent(), context.getRegion());
SynthStyle oldStyle = context.getStyle();
if (newStyle != oldStyle) {
if (oldStyle != null) {
oldStyle.uninstallDefaults(context);
}
context.setStyle(newStyle);
if (newStyle instanceof SeaGlassStyle) {
((SeaGlassStyle) newStyle).installDefaults(context, ui);
}
}
return newStyle;
}
示例8: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private void updateStyle(JTextComponent comp) {
SeaGlassContext context = getContext(comp, ENABLED);
SynthStyle oldStyle = style;
style = SeaGlassLookAndFeel.updateStyle(context, this);
if (style != oldStyle) {
SeaGlassTextFieldUI.updateStyle(comp, context, getPropertyPrefix());
if (oldStyle != null) {
uninstallKeyboardActions();
installKeyboardActions();
}
}
context.dispose();
}
示例9: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private void updateStyle(JComponent c) {
SeaGlassContext context = getContext(c, ENABLED);
// Note: JViewport is special cased as it does not allow for
// a border to be set. JViewport.setBorder is overriden to throw
// an IllegalArgumentException. Refer to SynthScrollPaneUI for
// details of this.
SynthStyle newStyle = SynthLookAndFeel.getStyle(context.getComponent(), context.getRegion());
SynthStyle oldStyle = context.getStyle();
if (newStyle != oldStyle) {
if (oldStyle != null) {
oldStyle.uninstallDefaults(context);
}
context.setStyle(newStyle);
newStyle.installDefaults(context);
}
this.style = newStyle;
context.dispose();
}
示例10: getMinimumSize
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getMinimumSize(javax.swing.JComponent)
*/
public Dimension getMinimumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
final SynthStyle style2 = ss.getStyle();
Dimension size = style2.getGraphicsUtils(ss).getMinimumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(), b.getVerticalAlignment(),
b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
b.getIconTextGap(), b.getDisplayedMnemonicIndex());
ss.dispose();
return size;
}
示例11: getPreferredSize
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getPreferredSize(javax.swing.JComponent)
*/
public Dimension getPreferredSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
SynthStyle style2 = ss.getStyle();
SynthGraphicsUtils graphicsUtils = style2.getGraphicsUtils(ss);
Dimension size = graphicsUtils.getPreferredSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(),
b.getVerticalAlignment(), b.getHorizontalTextPosition(),
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
ss.dispose();
// Make height odd.
size.height &= ~1;
return size;
}
示例12: getMaximumSize
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getMaximumSize(javax.swing.JComponent)
*/
public Dimension getMaximumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
final SynthStyle style2 = ss.getStyle();
Dimension size = style2.getGraphicsUtils(ss).getMaximumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(), b.getVerticalAlignment(),
b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
b.getIconTextGap(), b.getDisplayedMnemonicIndex());
ss.dispose();
return size;
}
示例13: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private void updateStyle(JToolBar c) {
SeaGlassContext context = getContext(c, Region.TOOL_BAR_CONTENT, null, ENABLED);
contentStyle = SeaGlassLookAndFeel.updateStyle(context, this);
context.getComponent().setOpaque(false);
context.dispose();
context = getContext(c, Region.TOOL_BAR_DRAG_WINDOW, null, ENABLED);
context.getComponent().setOpaque(false);
dragWindowStyle = SeaGlassLookAndFeel.updateStyle(context, this);
context.dispose();
context = getContext(c, ENABLED);
context.getComponent().setOpaque(false);
SynthStyle oldStyle = style;
style = SeaGlassLookAndFeel.updateStyle(context, this);
if (oldStyle != style) {
handleIcon = style.getIcon(context, "ToolBar.handleIcon");
if (oldStyle != null) {
uninstallKeyboardActions();
installKeyboardActions();
}
}
context.dispose();
}
示例14: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private void updateStyle(JComponent c) {
SeaGlassContext context = getContext(c, ENABLED);
Window window = SwingUtilities.getWindowAncestor(popupMenu);
if (PlatformUtils.isMac() && window != null) {
WindowUtils.makeWindowNonOpaque(window);
}
SeaGlassStyle oldStyle = style;
SynthStyle s = SeaGlassLookAndFeel.updateStyle(context, this);
if (s instanceof SeaGlassStyle) {
style = (SeaGlassStyle) s;
if (style != oldStyle) {
if (oldStyle != null) {
uninstallKeyboardActions();
installKeyboardActions();
}
}
}
context.dispose();
}
示例15: updateStyle
import javax.swing.plaf.synth.SynthStyle; //导入依赖的package包/类
private void updateStyle(JScrollPane c) {
SeaGlassContext context = getContext(c, ENABLED);
SynthStyle oldStyle = style;
style = SeaGlassLookAndFeel.updateStyle(context, this);
if (style != oldStyle) {
Border vpBorder = scrollpane.getViewportBorder();
if ((vpBorder == null) || (vpBorder instanceof UIResource)) {
scrollpane.setViewportBorder(new ViewportBorder(context));
}
if (oldStyle != null) {
uninstallKeyboardActions(c);
installKeyboardActions(c);
}
}
context.dispose();
}