Sanjay Jain
Sanjay Jain

Reputation: 61

Alternative for AnyLogic deprecated method getJComponent()?

I recently updated to AnyLogic PLE 8.4.0 and Java SE 12 on my Windows 10 laptop. And now an AnyLogic model that used to work earlier stops with the error "The method getJComponent() is undefined for the type ShapeTextField." I looked it up in AnyLogic/Help and I notice that getJComponent is identified as "Deprecated" and no alternative is identified. It appears to me that some mismatch happened between AnyLogic and Java updates that resulted in this error. I would appreciate any workarounds to get the model working.

Tried replacing getJComponent() with the following:

The code is:

((JTextField)(editbox.getJComponent())).setHorizontalAlignment(JTextField.LEFT);

This is defined in Simulation - Simulation Experiment / Java Actions/ Initial Experiment Setup field

Expected result: No error message. And the model should proceed to run window.

Upvotes: 2

Views: 136

Answers (1)

Sanjay Jain
Sanjay Jain

Reputation: 61

Thanks to the inputs from @Benjamin and @Felipe the following worked:

  1. I replaced the editbox and buttons with corresponding artifacts from AL8.4 palette. I copied the code from the earlier artifacts to corresponding fields in the new artifacts. I deleted the artifacts that were from AL7.
  2. I commented out the line that was meant to align the editbox since that capability is not available anymore.

With the above two changes I didn't get the error message about undefined method. The editbox and buttons worked and allowed me to enter XML filename and reading it with an XML parser routine. I have now run into issue with JAXB integration with AL8.4 and haven't been able to get past that yet. I will be posting that as a separate question.

Upvotes: 1

Related Questions