Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when copying/cutting text from a RTextArea #490

Closed
priand opened this issue Feb 13, 2023 · 2 comments
Closed

ClassCastException when copying/cutting text from a RTextArea #490

priand opened this issue Feb 13, 2023 · 2 comments
Assignees
Labels
Milestone

Comments

@priand
Copy link

priand commented Feb 13, 2023

Description
A class cast exception happens when a user cut/copy the text contains in a RTextArea (-> not the syntax text one):

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class org.monflabs.devtoolbox.swing.components.TextArea cannot be cast to class org.fife.ui.rsyntaxtextarea.RSyntaxTextArea (org.monflabs.devtoolbox.swing.components.TextArea and org.fife.ui.rsyntaxtextarea.RSyntaxTextArea are in unnamed module of loader 'app')
	at org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit$CopyCutAsStyledTextAction.actionPerformedImpl(RSyntaxTextAreaEditorKit.java:684)
	at org.fife.ui.rtextarea.RecordableTextAction.actionPerformed(RecordableTextAction.java:106)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)

It happens in this statement:
((RSyntaxTextArea)textArea).copyAsStyledText(theme);

When I look at the editor kit assigned to the RTextArea, it is of class org.fife.ui.rtextarea.RTextAreaEditorKit, so I'm not sure how it delegates to RSyntaxTextAreaEditorKit

Steps to Reproduce
Create an application with both a RTextArea and a RSyntaxTextArea. In the former, display the popup menu and select 'copy' or 'cut'

Expected behavior
Test should be properly copied

Actual behavior
Text is not copied and an exception is thrown

Java version
17

@priand priand added the bug label Feb 13, 2023
@bobbylight bobbylight self-assigned this Feb 19, 2023
@bobbylight bobbylight added this to the 3.3.3 milestone Feb 19, 2023
@bobbylight
Copy link
Owner

This should be fixed in a more robust way, but fixing this in the simplest way possible for now. The actual issue is how how RTextArea and RSyntaxTextArea instances share the actions displayed in their context menus, which means if you mix both components in an application, they'll both get the RSTA actions.

@priand
Copy link
Author

priand commented Feb 22, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants