Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: JComboBox with IDentifiers

Reply
Thread Tools

Re: JComboBox with IDentifiers

 
 
Sax@DIST.remove-nlb-this
Guest
Posts: n/a
 
      08-13-2012
From: "Sax@DIST" <(E-Mail Removed)>

Hi People,
thanks a lot for your kind replies. 0

I'll (try to) follow your suggests for JAVA programming in the future, as I'm
working in JAVA language since a few days, and I didn't find any solution to my
needs, so I wrote this one in the while of finding info about my needs! 0;-P

BtW: which is the best place where to find (lots of simple) examples for
learning the JAVA philosophy; for example: a *good and simple* solution for
this problem? 08-?

PS: I must use the Eclipse environment in the development of this small
project, as it's part of a bigger one! 08-!

Thanks a lot again,
Roberto. 0



On Friday, August 10, 2012 11:41:33 PM UTC+2, Sax@DIST wrote:
> Hi Guys,
> here I am again with another amazing trouble! 0
> I need to create a JComboBox containing a list of Items,
> each of which has its own IDentifier!
> So: when I select an Item of the JComboBox,
> I need to get its IDentifier
> (ie: its ID in a DataBase Table).
> I wrote the following four classes example,
> and I hope this could help someone else with my same needs!
> ...
>


--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      08-13-2012
To: Sax@DIST
From: markspace <-@.>

On 8/12/2012 2:03 PM, Sax@DIST wrote:

> BtW: which is the best place where to find (lots of simple) examples
> for learning the JAVA philosophy; for example: a *good and simple*
> solution for this problem? 08-?



Well, I still don't know what the problem is, other than "I don't know Java."
(Note spelling--not all caps.) Anything you read now should help, since you
are just beginning. Here's two ideas, both from the Java tutorial (which you
should certainly read).

JCombobox:

<http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html>

Database connections:

<http://docs.oracle.com/javase/tutorial/jdbc/index.html>

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
Sax@DIST.remove-nlb-this
Guest
Posts: n/a
 
      08-13-2012
To: markspace
From: "Sax@DIST" <(E-Mail Removed)>

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
0



On Sunday, August 12, 2012 11:37:51 PM UTC+2, markspace wrote:
> On 8/12/2012 2:03 PM, Sax@DIST wrote:
> > BtW: which is the best place where to find (lots of simple) examples
> > for learning the JAVA philosophy; for example: a *good and simple*
> > solution for this problem? 08-?

>
> Well, I still don't know what the problem is, other than "I don't know
> Java." (Note spelling--not all caps.) Anything you read now should
> help, since you are just beginning. Here's two ideas, both from the
> Java tutorial (which you should certainly read).
> JCombobox:
> <http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html>
> Database connections:
> <http://docs.oracle.com/javase/tutorial/jdbc/index.html>
>


--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      08-13-2012
To: Sax@DIST
From: Daniele Futtorovic <(E-Mail Removed)>

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
> 0


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...html#setRender
er(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.

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JComboBox with IDentifiers Roberto Sagoleo Java 8 08-22-2012 10:30 AM
Re: JComboBox with IDentifiers Sax Java 1 08-13-2012 07:38 PM
Re: JComboBox with IDentifiers Lew Java 0 08-11-2012 06:17 PM
Re: JComboBox with IDentifiers markspace Java 0 08-11-2012 06:17 PM
Binding identifiers to known or unknown identifiers latashag@live.com Java 1 04-22-2008 04:54 AM



Advertisments