Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mouseEntered method

 
linus dale
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



doubt
line no. 68 to 69
is this
Button b=((Button)e.getSource());
typecasting
what does this line do?
what is the use of getSource,getLabel,setText
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For events like mouse events, e.getSource() refers to component which fired the event. So say if you have a button and attach a MouseListener to it like below .... then the MouseEvent e.getSource would be a Button.



The casting is make sure the event is indeed a button and not object.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Linus, you've been asking quite a few starter questions lately. Perhaps it is a good idea to read through the Java Tutorial. This particular subject is discussed in its Swing section mostly.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:This particular subject is discussed in its Swing section mostly.
Agree. Moving.
 
linus dale
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Linus, you've been asking quite a few starter questions lately. Perhaps it is a good idea to read through the Java Tutorial. This particular subject is discussed in its Swing section mostly.

thanks
problem is I am a not much of a reader
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic