Re: adding new textfield after window already drawn--partially working
- From: Brandon McCombs <none@xxxxxxxx>
- Date: Sun, 29 Jan 2006 09:55:43 GMT
Brandon McCombs wrote:
Monique Y. Mudama wrote:On 2006-01-28, Brandon McCombs penned:revalidate() was what I needed to do and then a repaint() so that fixes the window resizing that was needed to make the new textfields appear.Brandon McCombs wrote:hello,
I have a JDIalog window that is created when a user double clicks on an entry in a JList. The list contains LDAP objects and the attributes and attribute values for the object are shown in the JDialog. Since the # of attribs/vals varies I dynamically build the textfields to show all of them. I am trying to add ability to add another value for any particular attribute. I got code in place that is able to determine where in the window to create the text field but the field doesn't show up. I've called paint() to make the JDialog redraw in the hopes it was that easy but it didn't work. Am I going to be forced to move all textfields that are below the location where the new one goes so that they make room for the new one? What is the normal way to attempt something like this? I'm using gridbag layout if that matters and I have a grid setup that lines up the textfields (values of attributes) with labels (attribute names). thanksSoon after I posted this I tried to resize the window and that made the new text field show up however I lose my vertical scroll bar for some reason as soon as I resize. Also, starting on the 3rd attribute for the objects I get the new textfield showing up over top of the existing textfield for that attribute and whatever is causing that makes any other textfield created below that position be off by 1. That is probably something in my code doing that (no clue why though) but does anyone know how I can get the textfield to show up w/o having to resize the window and how to fix the vertical scroll bar? thanks
Have you tried calling repaint() on the JDialog instead of paint()?
The only problem I have left now is that when I add a new textfield so another value can be added to an attribute I don't get the results I want if the total # of values is equal to the index of the attribute in my array. If I add any textfields for new values to any attribute past the one at index 2 (the 3rd one) then the new textfield is placed at what seems to be the gridy=1 value of my panel (panel contains all textfields and attribute name for 1 attribute). And if I keep adding textfields to that same attribute then the textfield with gridy value equal to the index value of the attributename ends up going over top of the original textfield and then the next one gets placed after the original text field(which is where I want *all* new textfields to be placed).
one whole panel ----------------------- |attribute1name|value1| ---------------------- | |value2| ----------------------| | |newval| <-this is where I want new ones to be placed -----------------------
one whole panel -----------------------| | |newval1| <-- this is where they get put instead -----------------------| If attrib2 index in my array is 3 | |newval2| then newval3 would end up going on top of -----------------------| the existing value1 textfield with |attribute2name|value1 | subsequent textfields actually going -----------------------| after value2 where I wanted them in the | |value2 | first place. -----------------------|
any ideas? My constraints.gridy values are correct but they just don't seem to be getting obeyed when I add the textfields to the Jpanel
I finally fixed this by removing all components from the specific JPanel I was working with and then re-adding them everytime a new textfield was added, and right before repainting i would actually add the new textfield. That took care of the misplacement of the new one.
.
- References:
- adding new textfield after window already drawn
- From: Brandon McCombs
- Re: adding new textfield after window already drawn--partially working
- From: Brandon McCombs
- Re: adding new textfield after window already drawn--partially working
- From: Monique Y. Mudama
- Re: adding new textfield after window already drawn--partially working
- From: Brandon McCombs
- adding new textfield after window already drawn
- Prev by Date: Re: TextField Increment/Decrement Buttons
- Next by Date: Re: TextField Increment/Decrement Buttons
- Previous by thread: Re: adding new textfield after window already drawn--partially working
- Next by thread: TextField Increment/Decrement Buttons
- Index(es):