Login  Register

Re: Displaying HTML message with no extra beeps

Posted by Michael Schmid on Jan 09, 2015; 4:38pm
URL: http://imagej.273.s1.nabble.com/Displaying-HTML-message-with-no-extra-beeps-tp5011078p5011157.html

Hi everyone,

in case someone else should need it, in the meanwhile I found a solution for suppressing the beep when typing <ENTER> in a readonly (non-editable) JEditorPane:

        editorPane.getActionMap().put("insert-break", new AbstractAction(){      
                        public void actionPerformed(ActionEvent e) {}
                }); //suppress beep on <ENTER> key

So the trick is entering an empty action for 'insert-break' (a funny name for pressing the ENTER key; the other actions have more meaningful names).  Having an empty 'beep' action did not help.

Michael
________________________________________________________________
On Jan 4, 2015, at 21:48, Michael Schmid wrote:

> Hi to all Java Gurus out there:
>
> Currently I am trying to write a simple plugin that can display a HTML
> message, similar to the ImageJ-builtin HTMLDialog (and maybe for
> eventually replacing it?), but with the possibility to show longer
> messages with scrollbars, and possibly more bells & whistles (hyperlinks,
> copy).
>
> The usual way to do this seems to be a JEditorPane.
>
> The Problem: A readonly (non-editable) JEditorPane always beeps if one
> presses <DELETE> or <ENTER>; the latter is a nuisance: If the focus is in
> the text (the JEditorPane), not the 'OK' button, and the user presses
> <ENTER> to close the window, it beeps.
> Tried with Java 1.5 and 1.6.
>
> My code (including a test program) is below.
> I tried various things, including adding a DocumentFilter that does
> nothing on insert/replace/delete operations, to no avail.
>
> Does anyone have an idea how to avoid those beeps?
>
> Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html