Bug #5587
closed
long parameter values get replaced with scrollbar
Added by Daniel Crawl over 12 years ago.
Updated about 12 years ago.
Description
In the actor parameters dialog, if a parameter value has more characters than can fit in the text box, the text box is replaced with a scrollbar.
Files
I'm not sure what the bug is here, could you post a screenshot and/or a detailed description of how to replicate the issue?
To reproduce:
1. add actor to canvas
2. double click on actor to open actor parameters dialog
3. in one of the parameter value text boxes, insert characters until there's too many to fit in the box
I just checked, and this is still a problem. I added a screen shot.
Patricia fixed in r63735.
I'm reopening since this is occurring again. The steps in comment 2 will demonstrate the problem. I verified again that r63735 fixed the problem, so the regression has happened since then.
The problem is that JTextArea should not be used when there is just a single
line and no scroll bar.
http://docs.oracle.com/javase/tutorial/uiswing/components/textarea.html
says:
"If you need to obtain only one line of input from the user, you should use a text field."
It seems like part of the problem is that the JTextArea gets a scrollbar and wants more screen real estate, but the GridBagLayout in ptolemy.gui.Query
is not giving it space.
I'll look into this, but I'm not confident.
This is fixed.
I added code to Query:
protected static void _textAreaSetRowsAndRepackParent(JTextArea textArea,
int minimumNumberOfRows) {
// This method is based on code by Patricia Derler that was
// originally in PtolemyQuery.
// One test for this is to drag in a StringConst and type in
// lots of characters. You should get a scrollbar. See
// http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5587
if (textArea.getRows() < minimumNumberOfRows) {
textArea.setRows(textArea.getRows() + 1);
textArea.revalidate();
Component parent = textArea.getParent();
while ((parent != null) && !(parent instanceof ComponentDialog)) {
parent = parent.getParent();
}
if (parent instanceof ComponentDialog) {
ComponentDialog dialog = (ComponentDialog) parent;
dialog.doLayout();
dialog.pack();
}
}
}
This is based on code by Patricia that was in PtolemyQuery.
Now PtolemyQuery calls this method as well.
Original Bugzilla ID was 5587
Also available in: Atom
PDF