在 Java 中更改 ICEPDF 的外观和感觉

我使用 IcePDF 作为 PDF 查看器,PropertiesManager我可以启用/禁用功能,例如:


    SwingController controller = new SwingController();


    PropertiesManager properties = new PropertiesManager(System.getProperties(),

            ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));


    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_PRINT, false);

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION, false);

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITYPANE_ANNOTATION, false);

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_TOOLBAR_ROTATE, false);

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_SAVE, false);

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_TOOLBAR_FIT, false);


    SwingViewBuilder factory = new SwingViewBuilder(controller, properties);

但是我想改变Windows的外观和感觉,简单的UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());不起作用。有人可以解决吗?


呼如林
浏览 174回答 2
2回答

哈士奇WWW

我终于在代码的开头添加了:try {  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch (ClassNotFoundException | InstantiationException | IllegalAccessException        | UnsupportedLookAndFeelException e) {  System.err.println("[ err. ] " + e);}它有效。

摇曳的蔷薇

org.icepdf.ri.viewer.Launcher 类设置在查看器 jar 中找到的查看器 RI 的外观和感觉。这是一个较旧的类,但如果您想覆盖它,它仍然使用 PropertiesManager。你可以这样做:preferences.put("application.lookandfeel", "javax.swing.plaf.metal.MetalLookAndFeel");这是针对 ICEpdf 6.3.x 的,但如果您使用的是早期版本,则可以使用与原始帖子类似的模式。该值可以是 Swing 的任何有效外观。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java