This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Basic question " Watch "Basic question " New topic

Basic question

Golam Newaz
Ranch Hand

Joined: Jan 08, 2001
Posts: 64
I came with a very basic question about swing component. Could
anybody clear it out?
Sometimes i find class instance in both way.

label = new JLabel("Click.", JLabel.CENTER); // 1st statem
Jlabel label = new JLabel("Click.", JLabel.CENTER); // 2nd statem
In the 2nd statement, i am instantiating and intialising
Jlabel constructor as label and a copy of reference to
the Jlabel Object, isn't it?.
My question is that why sometimes we use the 1st statement to
give a same effect instead of second. In the 1st statement
there is no Jlabel Object?
Do appreciate if you clarify that.
Golam Newaz

Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
You must have created the container for the variable earlier in the program.
Campfire Stories has an amusing story which reviews how variables are created and initialized:

"JavaRanch, where the deer and the Certified play" - David O'Meara
Golam Newaz
Ranch Hand

Joined: Jan 08, 2001
Posts: 64
Thanks a lot for providing an amazing page my dear pal, Cindy.
Now almost clear about OO language. is our
object. You were controlling with one remote control and
when i asked help you gave me a copy of your remote control (
a copy of reference ) but object is same,
when your location (name of reference ) and my location is different,isn't it?
Thanks a lot,
Golam Newaz.
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
great goalm
It is sorta covered in the JavaRanch Style Guide.
subject: Basic question
jQuery in Action, 3rd edition