• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Buttons will not update

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having an issue with a program i am creating as part of an on-line Java course.

I have to create a game of battleships where the computer generates positions for a fleet of ships and the player shoots them down as fast as possible.
It also needs to have save/load functionality. This is where I have encountered a problem.

I have managed to read the positions etc for the fleet of ships that has to be loaded in. I have also managed to read in the shots that the user has fired. But i can not get these shots to show on screen like they do when i click on a button to shoot in this grid position.

Here is the code for shooting a ship (via pressing on its grid square (it works))


Here is the setGuiSquare method:


And here is the code that does work, but does not change the button like it does when you click on a button:


Note that the correct variables seem to be being passed into the method. The bnum (number of button in the array) seems to be correct and the correct char seems to also be being returned into the method (it is infact detecting if a ship has been hit)

has anyone got any idea why the buttons are not being changed?

I dont know if this is at all needed. But here is the whole class i have used for the GUI/game controll. I realise the code is messy.
Thank you for any help in advance!

reply
    Bookmark Topic Watch Topic
  • New Topic