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

Custom JComponent

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i have a Battle ship game im doing,

and i want each ship be a separate Component...

so i can add mouse listeners to them

ive extended JComponent and Component...

and when i do

ship BS = new Ship() // ship extends Component..

this should create an instance of ship with Component attributes right??

please help, what when i do the following:

if(e.getSource == BS)
{
// do something
}


nothing happens..

Justin


my code...


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's a starter, needs a bit more work to get the coords correct.
(have something else to do at present)

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sweet man, i knew i was on the right track..

just about 3/4 of a mile off : )

thanks,

Justin
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some changes to get the coords right

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic