Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #4231
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.n-ix.net!news.belwue.de!not-for-mail |
|---|---|
| From | Thomas Richter <thor@math.tu-berlin.de> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Aligned elements in a JComboBox |
| Date | Tue, 17 May 2011 21:41:23 +0200 |
| Organization | InterNetNews at News.BelWue.DE (Stuttgart, Germany) |
| Lines | 57 |
| Message-ID | <iquj14$f38$1@news.belwue.de> (permalink) |
| References | <iqu8i1$ks3$1@news.belwue.de> <JGxAp.4755$iv4.3479@newsfe09.iad> |
| NNTP-Posting-Host | vpn-m-8d3a2f3a.campus.uni-stuttgart.de |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.belwue.de 1305661284 15464 141.58.47.58 (17 May 2011 19:41:24 GMT) |
| X-Complaints-To | news@news.belwue.de |
| NNTP-Posting-Date | Tue, 17 May 2011 19:41:24 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 |
| In-Reply-To | <JGxAp.4755$iv4.3479@newsfe09.iad> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4231 |
Show key headers only | View raw
On 17.05.2011 18:49, Knute Johnson wrote: > On 05/17/2011 09:42 AM, Thomas Richter wrote: >> Hi folks, >> >> the problem at hand is how to align individual components that are part >> of a JComboBox. >> >> The JComboBox uses a custom Renderer to render its contents, and each >> content consists of two strings of variable size, arranged in a JPanel. >> The getListCellRendererComponent() of the renderer now returns the >> JPanel containing the two components. >> >> So far, so good. This works. >> >> The problem is that the sizes of the two components differ througout the >> items of the JComboBox, which means that the elements within the JList >> in the JCombobox (or rather, its JList rendering the non-editable items) >> are not aligned to each other. Of course they can't, they are individual >> JPanels each with its own layout manager, and thus do not know anything >> on each other. >> >> Needless to say, this looks visually very unattractive. >> >> So what can I do about this? I have a JComboBox with a very complex >> layout and the requirement that each entry necessarily is a pair of data >> types of various sizes. How can I make the elements be aware of each >> other and have a common layout for all of them? >> >> Illustration: >> >> +----------------------------------------------+ >> | foofoo | barbarbarbarbarbarbarbar | >> +----------------------------------------------+ >> | foofoofoofoofoofoofoo | bar | >> +----------------------------------------------+ >> >> This is how the JComboBox currently renders. But I want it >> laid out such that the separator between the two elements forming one >> entry of it are underneath each other. >> >> Any ideas? >> >> Greetings, >> Thomas > > Figure out the largest size of your data in each field and lay out all > the elements with the same width and layout manager. Which layout manager accepts fixed widths for its components? If I use a GridBagLayout, for example, changing the dimension of the components within changes their alignment, and thus they'll move around even though the layout manager stays the same. Greetings, Thomas
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Aligned elements in a JComboBox Thomas Richter <thor@math.tu-berlin.de> - 2011-05-17 18:42 +0200
Re: Aligned elements in a JComboBox Knute Johnson <nospam@knutejohnson.com> - 2011-05-17 09:49 -0700
Re: Aligned elements in a JComboBox Thomas Richter <thor@math.tu-berlin.de> - 2011-05-17 21:41 +0200
Re: Aligned elements in a JComboBox Knute Johnson <nospam@knutejohnson.com> - 2011-05-17 18:00 -0700
Re: Aligned elements in a JComboBox Bent C Dalager <bcd@pvv.ntnu.no> - 2011-05-18 09:13 +0000
Re: Aligned elements in a JComboBox "John B. Matthews" <nospam@nospam.invalid> - 2011-05-18 07:56 -0400
Re: Aligned elements in a JComboBox Roedy Green <see_website@mindprod.com.invalid> - 2011-05-19 10:29 -0700
csiph-web