processing.mode.java.JavaEditor cannot be cast to processing.mode.java.JavaEditor

I am currently updating my Presenter Tool to Processing 3. It opens several Sketches and triggers open Editors to presentation mode.

Therefore i am collecting all open Editors: List <Editor> editors = base.getEditors();

In Processing 2 i could cast the Editor to a JavaEditor and call handlePresent(): JavaEditor je = (JavaEditor)editors.get( (int)random( editors.size()-1 ) ); je.handlePresent();

Unfortunately this raises a ClassCastException in Processing 3: java.lang.ClassCastException: processing.mode.java.JavaEditor cannot be cast to processing.mode.java.JavaEditor

Eclipse does not raise an error. The error shows when opening the tool in Processing 3. Screen Shot 2016-01-21 at 15.18.16

Any ideas? Tomorrow's semester presentation.

Answers

  • Update: My tool code didn't find import processing.mode.java.*;

    So i compiled processing-java and added the .jar to the libs of the tool.

    If i remove the .jar Processing does not find processing.mode.java.* when opening the tool: Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: processing/mode/java/JavaEditor

  • edited January 2016

    I also couldn't import processing.mode.java.JavaEditor; in both P3 & P2.
    So I couldn't help you. However, there's a little logic error in this expression here:
    (int) random( editors.size() - 1 ).

    The last Editor item of that List won't ever be randomly picked! @-)
    Just remove the minus 1 - 1 there: (int) random( editors.size() ). ;)

  • JavaEditor worked in my case in P2. The tool worked like a charm.

Sign In or Register to comment.