本文整理汇总了Java中javax.swing.plaf.synth.SynthLookAndFeel类的典型用法代码示例。如果您正苦于以下问题:Java SynthLookAndFeel类的具体用法?Java SynthLookAndFeel怎么用?Java SynthLookAndFeel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SynthLookAndFeel类属于javax.swing.plaf.synth包,在下文中一共展示了SynthLookAndFeel类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SynthLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JScrollBar().setUI(new SynthScrollBarUI() {
protected void configureScrollBarColors() {
super.configureScrollBarColors();
isMethodCalled = true;
}
});
if (!isMethodCalled) {
throw new RuntimeException("The configureScrollBarColors was not called");
}
}
});
}
示例2: main
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SynthLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JSlider slider = new JSlider();
HackedSynthSliderUI ui = new HackedSynthSliderUI(slider);
slider.setUI(ui);
if (ui.counter != 111) {
throw new RuntimeException("Some installers of SynthSliderUI weren't invoked");
}
slider.setUI(null);
if (ui.counter != 0) {
throw new RuntimeException("Some uninstallers of SynthSliderUI weren't invoked");
}
}
});
}
示例3: main
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SynthLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JSlider slider = new JSlider();
slider.setUI(new SynthSliderUI(slider) {
@Override
protected void paintTrack(SynthContext context, Graphics g, Rectangle trackBounds) {
throw new RuntimeException("Test failed: the SynthSliderUI.paintTrack was invoked");
}
});
slider.setPaintTrack(false);
slider.setSize(slider.getPreferredSize());
BufferedImage bufferedImage = new BufferedImage(slider.getWidth(), slider.getHeight(),
BufferedImage.TYPE_INT_ARGB);
slider.paint(bufferedImage.getGraphics());
}
});
}
示例4: main
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SynthLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JFrame frame = new JFrame();
JTable table = new JTable(new Object[][]{{"1", "2"}, {"3", "4"}},
new Object[]{"col1", "col2"});
frame.getContentPane().add(new JScrollPane(table));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
示例5: validate
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
private static void validate() throws Exception {
Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");
getSelectedUIMethod.setAccessible(true);
Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");
getSelectedUIStateMethod.setAccessible(true);
if (getSelectedUIMethod.invoke(null) != componentUI) {
throw new RuntimeException("getSelectedUI returns invalid value");
}
if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
(SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
throw new RuntimeException("getSelectedUIState returns invalid value");
}
}
示例6: main
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
lookAndFeel.load(new ByteArrayInputStream(synthXml.getBytes("UTF8")),
bug8040328.class);
UIManager.setLookAndFeel(lookAndFeel);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
final JFrame frame = new JFrame();
try {
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
test(frame);
} finally {
frame.dispose();
}
}
});
System.out.println("ok");
}
示例7: fixGtkPopupStyle
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的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);
}
示例8: patchGtkDefaults
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的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));
}
}
示例9: SynthTableColors
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的package包/类
public SynthTableColors() throws Exception {
setTitle(System.getProperty("java.version"));
InputStream is = new ByteArrayInputStream(synthXml.getBytes("UTF8"));
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(is, SynthTableColors.class);
UIManager.setLookAndFeel(laf);
JTable table = new JTable();
configureTable(table);
JXTable xtable = new JXTable();
configureTable(xtable);
add(createTab(table, xtable));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
}
示例10: updateStyle
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的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;
}
示例11: updateStyle
import javax.swing.plaf.synth.SynthLookAndFeel; //导入依赖的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();
}