Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1961

Re: Creating a component

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "tar" <tar@THRWHITE.remove-dii-this>
Subject Re: Creating a component
Message-ID <ymisl82pwir.fsf@sevak.isi.edu> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <ejmnl4-abc.ln1@Father.family>
References <ejmnl4-abc.ln1@Father.family>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 37
Date Wed, 27 Apr 2011 15:36:21 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918581 96.60.20.240 (Wed, 27 Apr 2011 10:36:21 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:36:21 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1961

Show key headers only | View raw


  To: comp.lang.java.gui

Ricardo Palomares Martinez <rpm.PUBLI@iespana.es> writes:

> There is somewhat usual to have a JTextField for the user to type a
> pathname, and a JButton next to it to launch a Choose File Dialog. In
> fact, in the app I'm writing is going to be usual that I'd rather
> create a custom component to tie both fields together.
> 
> But I'm not sure how to do that. I've thought of putting both
> components (JTextField and JButton) inside a JPanel, and thus I would
> write my custom component by extending a JPanel with two private
> properties holding the text field and the button. Would that be
> sensible or should I extend JComponent (which I think is more complex)?

That is quite sensible.  Extending JPanel is probably the easiest way to
do this, as you observe.  The only thing that can get tricky if you go
this route is that if you have multiple instances of this, you might
find it tricky to make sure the layout aligns properly if each one lays
out differently.  Particularly if there is an associated label, which
may be a different size in each item.

You also want to make sure you have reasonable resizing behavior in the
JPanel, which can probably be achieved most easily with BorderLayout
with the text field in the center, with label left and button right.

Note that you may also want to include a JLabel to identify what
pathname this is supposed to be.


-- 
Thomas A. Russ,  USC/Information Sciences Institute

---
 * 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 | NextPrevious in thread | Find similar


Thread

Creating a component by p "Ricardo Palomares Martine" <ricardo.palomares.martine@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
  Re: Creating a component "CK" <ck@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
  Re: Creating a component "Robert" <robert@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
  Re: Creating a component "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
  Re: Creating a component "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000

csiph-web