Synthetica look and feel throws a class cast exception when using JLayer with JscrollPane with Java 11

56 views Asked by At

Synthetica look and feel throws a class cast exception when using JLayer with JscrollPane with Java 11. It works fine with Java 8. Is there a way to fix this?

Code example

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();
    }
  }

}

Error stacktrace

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)

It works fine with Java 8

1

There are 1 answers

0
wzberger On

The issue is fixed in V2.34.0 / V3.5.0.