Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

adding new textfield after window already drawn

Thread view: 
Brandon McCombs - 28 Jan 2006 06:30 GMT
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). thanks
Brandon McCombs - 28 Jan 2006 07:29 GMT
> hello,
>
[quoted text clipped - 12 lines]
> a grid setup that lines up the textfields (values of attributes) with
> labels (attribute names). thanks

Soon 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
Monique Y. Mudama - 28 Jan 2006 18:41 GMT
>> hello,
>>
[quoted text clipped - 24 lines]
> 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()?

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Brandon McCombs - 28 Jan 2006 19:14 GMT
>>> hello,
>>>
[quoted text clipped - 25 lines]
>
> Have you tried calling repaint() on the JDialog instead of paint()?

actually i think i was using repaint() even though I said i was using
paint() and I had removed the line b/c it didn't make a difference but I
put repaint() in just now and it didn't make a difference still  ( had
to resize the window a pixel before the new field showed up).
Brandon McCombs - 28 Jan 2006 22:16 GMT
>>> hello,
>>>
[quoted text clipped - 25 lines]
>
> Have you tried calling repaint() on the JDialog instead of paint()?

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.

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
Brandon McCombs - 29 Jan 2006 09:55 GMT
>>>> hello,
>>>>
[quoted text clipped - 64 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.