Error message with selectable text
When Kepler displays an error message in the pop-up dialog, the text is not selectable so I can copy-paste it into an email. This makes it tedious to report errors or problems, because I have to retype the whole message.
#1 Updated by Christopher Brooks almost 10 years ago
This would likely be an issue with the Ptolemy Query widget in ptolemy.gui.
I tend not to see this because most error dialogs should be thrown with
an Exception and the dialog should have a "Show Stack Trace" button.
The error message is selectable in the Stack Trace Window.
However, if someone is invoking GraphicalMessageHandler directly, then
the text is probably not selectable.
#3 Updated by Christopher Brooks almost 10 years ago
I'm lowering the priority of this and changing it to an enhancement because
the code works as expected.
I agree that it would be nice if the dialog text was selectable, retyping
an error message is a waste of human effort.
ptolemy.gui.UndeferredGraphicalMessageHandler which uses JOptionPane.
It appears to be a limitation of JOptionPane that the text is not selectable.
for JOptionPane examples,
However, all is not lost. JOptionPane has a message argument and if that
argument is a String, then a JLabel is created.
A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
The Component is displayed in the dialog.
The Icon is wrapped in a JLabel and displayed in the dialog.
The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
So instead of passing a String, I created a method that creates a JTextArea
that looks like a JLabel, but is selectable. I found code at
that got me most of the way there.
So, I modified ptolemy.gui.UndeferredGraphicalMessageHandler so that we
use a JTextField, which looks like a JLabel, but is selectable.
As a fallback, we will return a String if there is a problem.
#8 Updated by Christopher Brooks almost 7 years ago
In 2009-08-11, Ben wrote:
Now I'm seeing a frame that is too small to accommodate the text and the
buttons - they are chopped off.
The text is wrapping, however!
I'm using MessageHandler.error(String, throwable)
I can't reproduce this.
This can probably be closed. I'm assigning it to Ben pending his approval.