This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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