Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #17791
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JComboBox with IDentifiers |
| Date | Mon, 13 Aug 2012 18:49:20 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 38 |
| Message-ID | <k0bb6s$k60$1@dont-email.me> (permalink) |
| References | <08a4e9e5-be46-4a15-94c4-e6bfab71d781@googlegroups.com> <2eae09a5-6d01-401a-acb0-cc54ba8b516e@googlegroups.com> <k097nl$1is$1@dont-email.me> <5a6762d4-5fb9-451d-86eb-98c26f3ef95a@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Mon, 13 Aug 2012 16:49:32 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="f5413cdf228456e5cdb66b1fa4498c4d"; logging-data="20672"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19q9wgvzGuvbv2sH8X4+SB8" |
| User-Agent | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 |
| In-Reply-To | <5a6762d4-5fb9-451d-86eb-98c26f3ef95a@googlegroups.com> |
| Cancel-Lock | sha1:0fWTa+e84pNlXdrIj6e3Q9/uWDA= |
| Xref | csiph.com comp.lang.java.programmer:17791 |
Show key headers only | View raw
On 13/08/2012 18:22, Sax@DIST allegedly wrote: > Hi markspace, > thanks a lot for the two links you suggested me about the Java Programming Language! 0;-) > > The first one, about the "correct" usage of JComboBox itself, is very detailed and I think I can find what I need, reading the lots of examples. > > The second one, about the database connection, will be very useful for me, as I need to get the data for the items of my JComboBox from a DataBase Table. > > After all, my needs are very simple: > (o) to read some records (fields required: 'IDentifier' and 'Description') from a DB-Table > (o) to show the 'Description' of the records as Items of the JComboBox > (o) to do something else with the 'IDentifier' of the selected Item within the JComboBox > > Thanks again for your precious help, > Greetings. > Roberto > 08-) Hi Roberto, You should create a custom data structure containing the data you need (identifier and representation, from the looks of it), add them to the JComboBox's contents, and use a custom renderer (<http://docs.oracle.com/javase/6/docs/api/javax/swing/JComboBox.html#setRenderer(javax.swing.ListCellRenderer)>). That way, the _items_ in the combo box will always be your custom data structure instances (which you can use in #setSelectedItem(Object), for instance; or returned by #getSelectedItem()), and the renderer controls how they're displayed. In addition -- I believe I've already seen something like this coded somewhere -- you can write your own custom model (<http://docs.oracle.com/javase/6/docs/api/javax/swing/ComboBoxModel.html>) and have that hook directly to the database, possibly with on-demand, lightweight loading of data. HTH, -- DF.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JComboBox with IDentifiers Roberto Sagoleo <roberto.sagoleo@gmail.com> - 2012-08-10 14:41 -0700
Re: JComboBox with IDentifiers markspace <-@.> - 2012-08-10 15:14 -0700
Re: JComboBox with IDentifiers Lew <lewbloch@gmail.com> - 2012-08-10 15:26 -0700
Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-12 14:03 -0700
Re: JComboBox with IDentifiers markspace <-@.> - 2012-08-12 14:37 -0700
Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-13 09:22 -0700
Re: JComboBox with IDentifiers Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-08-13 18:49 +0200
Re: JComboBox with IDentifiers Roedy Green <see_website@mindprod.com.invalid> - 2012-08-14 18:02 -0700
Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-22 03:30 -0700
csiph-web