AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Associating user data with AWT/Swing component?

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Dr. Len
Guest





PostPosted: Thu Jun 17, 2004 12:17 pm    Post subject: Associating user data with AWT/Swing component? Reply with quote



Hi NG,

Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?
I have multiple JTextFields in my JPanel, with the panel being their
keylistener. In the KeyPressed, I would like to get component's user
data like so: event.getComponent().getUserData();

TIA.
Back to top
ak
Guest





PostPosted: Thu Jun 17, 2004 12:35 pm    Post subject: Re: Associating user data with AWT/Swing component? Reply with quote



Quote:
Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?
I have multiple JTextFields in my JPanel, with the panel being their
keylistener. In the KeyPressed, I would like to get component's user
data like so: event.getComponent().getUserData();

JComponent#getClientProperty(Object key)
JComponent#putClientProperty(Object key, Object value)

--
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader



Back to top
Andrew Thompson
Guest





PostPosted: Thu Jun 17, 2004 12:38 pm    Post subject: Re: Associating user data with AWT/Swing component? Reply with quote



On Thu, 17 Jun 2004 15:17:14 +0300, Dr. Len wrote:

Quote:
Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?

What the heck are you talking about?
What is the purpose of this 'Integer'?

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Back to top
Dr. Len
Guest





PostPosted: Fri Jun 18, 2004 8:08 am    Post subject: Re: Associating user data with AWT/Swing component? Reply with quote

On Thu, 17 Jun 2004 14:35:12 +0200, "ak" <spam (AT) imagero (DOT) com> wrote:

Quote:
Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?
I have multiple JTextFields in my JPanel, with the panel being their
keylistener. In the KeyPressed, I would like to get component's user
data like so: event.getComponent().getUserData();

JComponent#getClientProperty(Object key)
JComponent#putClientProperty(Object key, Object value)

Thanks, this is exactly what I was looking for.

Back to top
Frank D. Greco
Guest





PostPosted: Sun Aug 15, 2004 9:50 pm    Post subject: Re: Associating user data with AWT/Swing component? Reply with quote

Dr. Len <len (AT) wohoo (DOT) org> sez:

Quote:
Hi NG,

Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?
I have multiple JTextFields in my JPanel, with the panel being their
keylistener. In the KeyPressed, I would like to get component's user
data like so: event.getComponent().getUserData();

Why not subclass your component and put the data within your subclass?

Frank G.
+==========================================+
Quote:
Crossroads Technologies Inc. |
www.CrossroadsTech dot com |
fgreco at REMOVE!cross!roads!tech!dot!com|
+=========================================+


Back to top
zoopy
Guest





PostPosted: Sun Aug 15, 2004 11:34 pm    Post subject: Re: Associating user data with AWT/Swing component? Reply with quote

On 17-6-2004 14:38, Andrew Thompson wrote:

Quote:
On Thu, 17 Jun 2004 15:17:14 +0300, Dr. Len wrote:


Do Swing/AWT components have a simple facility for associating user
data (Integer) with the component?


What the heck are you talking about?
What is the purpose of this 'Integer'?

It's useful, for example, for the popup menu of a JTable with a JMenuItem to copy contents of a

cell. The table's mouselistener updates, just before showing the popup menu, the menu item with the
row and column on which was clicked [ copyMenuItem.putClientProperty(PROP_SEL_ROW, new
Integer(selRow)); ...]. The menu item's action listener retrieves, if and when it is executed, their
values [ copyMenuItem.getClientProperty(PROP_SEL_ROW); ... ], and thus knows which cell to copy. So,
its a sort of parameter passing... (and it avoids declaring and "misusing" member variables for this
purpose)

Regards,
Z.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.