Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2005

Tip: Looking for answers? Try searching our database.

Getting a Component name as a string

Thread view: 
ChooChooOnMyHead - 31 Aug 2005 16:13 GMT
Say I make an object,  a control.

JButton <i><b>Button_1</i></b> = new JButton("whatever");

now say i want to retrieve the name of the JButton,  that is
"Button_1",  as a string.  How do i do this.  I have extended buttons
with a setName()/getName() method but there must be an easier way than
wrapping every object i want to do this with. It is probably really
simple and I'm probably a total clown for not knowing, but any pointer
to where i can learn more about this would be appreciated.
Andrew Thompson - 31 Aug 2005 16:22 GMT
> now say i want to retrieve the name of the JButton,  that is
> "Button_1",  as a string.  How do i do this.  

Would that be a question?

If so - you might approach this by checking the methods
listed in the API JavaDocs for JButton.

What happened when you tried that?

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Then 'click' - left me alone on the phone, with the tone.."
Gangstarr 'Love Sick'

ChooChooOnMyHead - 31 Aug 2005 16:47 GMT
your sarcasm is always a delight.
i dind't see anything at a brief overview of that but no doubt i was
looking in the wrong place.  Also the object i am working with is not a
JButton,  It's a custome made extension of FileFilter,  a custom
extension of some Components,  and a few homemade objects as well,  so
a more global solution is necesary
Andrew Thompson - 31 Aug 2005 16:58 GMT
> your sarcasm is always a delight.

You're welcome.  Any time you should slouch in here
asking such apparently stupid questions.

> i dind't see anything at a brief overview

By 'brief overview', what do you mean?

Do you mean "After reading the docs on the 'get' methods
of JButton and it's superclasses.."?

>..of that but no doubt i was
> looking in the wrong place.  

Presuming you did that, then, no, that would be the right place.

>..Also the object i am working with is not a
> JButton,  It's a custome made extension of FileFilter,  

So.. what was the point of your example that mentioned
a JButton?

>..a custom
> extension of some Components,  and a few homemade objects as well,  

Extending what?  java.lang.HomeMadeJam ?
No?  Perhaps you can fill in the details there..

>..so a more global solution is necesary

<dripping with..>
Tried the UN?
</dripping with..>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Seen you on Aldebaran, safe on the green desert sand"
The Rolling Stones '2000 Light Years From Home'

Thomas Weidenfeller - 01 Sep 2005 08:05 GMT
> Say I make an object,  a control.

"control" is a Windows term. Please adapt common Java terminology so we
know what you want. Oh, and please don't even attempt to use HTML in
Usenet posts. Many people will ignore you already just for trying.

> JButton <i><b>Button_1</i></b> = new JButton("whatever");
>
> now say i want to retrieve the name of the JButton,  that is
> "Button_1",

No, that is not the name of the button. That is the name of a variable
which can hold a reference to a JButton, any subclass of a JButton or no
reference at all (null).

You lack some basic understanding of the Java language. Consider a good
introduction textbook.

> as a string.  How do i do this.  I have extended buttons
> with a setName()/getName() method but there must be an easier way than
> wrapping every object i want to do this with.

If you base your application design on naming things this way, then your
application design is seriously flawed. This smells like a severe lack
of understanding objects. An object is characterized by state, behavior
and identity. And the identity is not a name, but in the case of Java
the unique reference each object has. Variables holding identical
references are guaranteed to reference to the same object. An attempt to
establish an own identity system is at a minimum an attempt to re-invent
the wheel and a serious waste of time.

> simple and I'm probably a total clown for not knowing, but any pointer
> to where i can learn more about this would be appreciated.

A good Java introduction textbook.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.