Java 类javax.swing.plaf.synth.SynthLookAndFeel 实例源码

项目:jdk8u-jdk    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:jdk8u-jdk    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:jdk8u-jdk    文件:bug6923305.java   
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());
        }
    });
}
项目:jdk8u-jdk    文件:bug6913768.java   
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);
        }
    });
}
项目:jdk8u-jdk    文件:bug7143614.java   
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");
    }

}
项目:openjdk-jdk10    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:openjdk-jdk10    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:openjdk-jdk10    文件:bug6923305.java   
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());
        }
    });
}
项目:openjdk-jdk10    文件:bug6913768.java   
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);
        }
    });
}
项目:openjdk-jdk10    文件:bug7143614.java   
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");
    }

}
项目:openjdk-jdk10    文件:bug8040328.java   
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");
}
项目:openjdk9    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:openjdk9    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:openjdk9    文件:bug6923305.java   
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());
        }
    });
}
项目:openjdk9    文件:bug6913768.java   
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);
        }
    });
}
项目:openjdk9    文件:bug7143614.java   
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");
    }

}
项目:openjdk9    文件:bug8040328.java   
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");
}
项目:jdk8u_jdk    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:jdk8u_jdk    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:jdk8u_jdk    文件:bug6923305.java   
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());
        }
    });
}
项目:jdk8u_jdk    文件:bug6913768.java   
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);
        }
    });
}
项目:jdk8u_jdk    文件:bug7143614.java   
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");
    }

}
项目:lookaside_java-1.8.0-openjdk    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:bug6923305.java   
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());
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:bug6913768.java   
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);
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:bug7143614.java   
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");
    }

}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
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);
}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
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));
  }
}
项目:swingx    文件:SynthTableColors.java   
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);
}
项目:seaglass    文件:SeaGlassLookAndFeel.java   
/**
 * 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;
}
项目:seaglass    文件:SeaGlassViewportUI.java   
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();
}
项目:infobip-open-jdk-8    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:infobip-open-jdk-8    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:infobip-open-jdk-8    文件:bug6923305.java   
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());
        }
    });
}
项目:infobip-open-jdk-8    文件:bug6913768.java   
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);
        }
    });
}
项目:infobip-open-jdk-8    文件:bug7143614.java   
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");
    }

}
项目:jdk8u-dev-jdk    文件:bug6924059.java   
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");
            }
        }
    });
}
项目:jdk8u-dev-jdk    文件:bug6918861.java   
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");
            }
        }
    });
}
项目:jdk8u-dev-jdk    文件:bug6923305.java   
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());
        }
    });
}