在Java11中使用JscrollPane和JLayer时,Synthetica外观会引发类转换异常.它在Java 8中运行良好. Is there a way to fix this?
代码示例
public class TestFrame extends JFrame { TestFrame() { this.setSize(300,400); this.getContentPane().setLayout(new FlowLayout()); JTextArea textArea = new JTextArea(20, 20); JScrollPane scrollableTextArea = new JScrollPane(textArea); LayerUI<JScrollPane> layerUI = new LayerUI(); JLayer<JScrollPane> jLayer = new JLayer(scrollableTextArea, layerUI); this.add(jLayer); } public static void main(String[] args) { try { UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel()); TestFrame testFrame = new TestFrame(); testFrame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }
堆栈跟踪错误
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class javax.swing.JLayer cannot be cast to class javax.swing.JScrollPane (javax.swing.JLayer and javax.swing.JScrollPane are in module java.desktop of loader 'bootstrap') at de.javasoft.plaf.synthetica.painter.ScrollPanePainter.paintScrollPaneBorder(ScrollPanePainter.java:274) at de.javasoft.plaf.synthetica.painter.SyntheticaPainter.paintScrollPaneBorder(SyntheticaPainter.java:640) at java.desktop/javax.swing.plaf.synth.SynthScrollPaneUI.paintBorder(SynthScrollPaneUI.java:125) at java.desktop/javax.swing.plaf.synth.SynthBorder.paintBorder(SynthBorder.java:63) at java.desktop/javax.swing.JComponent.paintBorder(JComponent.java:967) at java.desktop/javax.swing.JComponent.paint(JComponent.java:1075) at java.desktop/javax.swing.JLayer.paint(JLayer.java:475) at java.desktop/javax.swing.plaf.LayerUI.paint(LayerUI.java:80) at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161) at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:797) at java.desktop/javax.swing.JLayer.paint(JLayer.java:470) at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907) at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083) at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907) at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083) at java.desktop/javax.swing.JLayeredPane.paint(JLayeredPane.java:590) at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907) at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5262)
它在Java 8中运行良好