Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1208
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: how to dynamically ad |
| Message-ID | <45fcda8d$0$28103$4c368faf@roadrunner.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1174053401.150153.259660@d57g2000hsg.googlegroups.com> |
| Date | 2011-04-27 15:31 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui fenton.travers@gmail.com wrote: > I'm just getting started with Swing. I saw the NetBeans GUI builder > tutorial and this blew me away. http://www.netbeans.org/kb/55/quickstart-gui.html. > However, when I want to do something beyond a rather static form, I > feel like there is probably a heck of a lot more that I need to > learn. Specifically if someone could point me in the right direction > to learn to do at least the following: > > I have a single text jTextField, if the user types something in it I > want a second jTextField to show up. I don't know where I should be > looking to come to understand how to do this type of ?animation?. If > someone could point me in the general area. Is this Java 2D? Is this > something else? I'd like to learn more on the topic, but first I need > to find out which topic I need to look into. Any advice is much > appreciated. > > Thx, > > fenton > To actually provide useful information unlike the other guys' responses, I'll give you a few points of advice. Issues concerning where you want the new field to show up within the same containing component such as above/below your existing field are irrelevant to providing some advice. If you want the new field to be in a dialog window then that would change the advice though. Under the assumption you want another text field to show up in the same component (Jpanel or Jframe) as the original text field you will need to probably need a document listener on the first textfield if you want simple typing to be the trigger for the 2nd field's appearance. Have the appropriate method of the document listener (DocumentListener is the class I believe) call the code that creates another JTextField. You will need to call the repaint() method of the component that contains those JTextField's so that the new field is actually visible. Issues concerning resizing, etc. will need addressed; I use the gridbag layout so I can define grid values for new components and that way I know exactly where they will show up. I believe the best practice for something like this though is to have the 2nd field always be visible but to be disabled until its use is required. That way the user is not surprised when the 2nd field appears out of no where (especially if you code it such that the window is automatically resized which you shouldn't do). --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Find similar | Unroll thread
how to dynamically add a "fenton.travers" <fenton.travers@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000 Re: how to dynamically ad "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000 Re: how to dynamically ad "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000 Re: how to dynamically ad "IchBin" <ichbin@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000 Re: how to dynamically ad "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
csiph-web