How to display form validation errors in settings panel


As in question, I need to add some validation to plugin settings form.

Is there any API to do such thing?

Comment actions Permalink
Official comment

There is the apply method in your configurable that throws an exception:


This method is called when you press OK or Apply.

If the exception is thrown its content is shown under the settings page:

Comment actions Permalink

--No such API, you need to manage error messages on your own--

Update: not correct, in fact API exists, see the answer provided by Sergey Malenkov 

Comment actions Permalink

Thanks a lot Sergey. Can I invoke SwingWorker on Apply action? and display SwingWorker job result on other place as message (or in the settings window, but I think it not possible)

Comment actions Permalink

Nope, because without exception the Settings dialog will be closed.

Comment actions Permalink

I meant closed by OK. Apply does not close the dialog, but you cannot destinguish OK and Apply via API.

Comment actions Permalink

Hi Sergey Malenkov

is this still valid ?
Or is it possible to directly have the validation to be triggered before pressing the apply button ?

I tried doing something like described here :

but it seems that the validation tooltip never shows :/ 
Or do I need something special to make it work on the settings panel ?

In worse case I'll do like said in this topic. But I found it nicer to warn the user directly without waiting him to click on apply :) 


Please sign in to leave a comment.