Hi there,
I have an 10 x 10 array of JButtons in my battleships project, which represent the sea. I was just wondering how do i find out which button the mouse cursor is over at any given time? I tried adding the following to the buttons:
board.addMouseM otionListener(n ew MouseMovingHand ler());
board.addMouseL istener(new MouseHandler()) ;
?
Cheers,
Ragaman
User Profile
Collapse
-
Mouse cursor over a JButton??
-
Mouse cursor over a JButton
Hello everyone,
I have an 10 x 10 array of JButtons in my battleships project, which represent the sea. I was just wondering how do i find out which button the mouse is over at any given time? I need to know this as i am designing a way to place the ships at the start and it will show which where the ship will be placed when the mouse cursor is over any button. I add a mouse listener to the players board :
board.addMouseM otionListener(n ew... -
Thank you for the advice, how do i go about setting the original repaint manager? -
Repaint Manager
Hello there,
I am developing a game in java and for the options menu at the start i install a NullRepaintMana ger to override paint requests.
I was wondering however how to later go back to not using this RepaintManger i.e disable this NullRepaintMang er and return to how repaint requests are normally handled?
Any help or advice would be greatly appreciated,
Cheers,
Ragaman
... -
Thank you for your suggestion!I was using null and i noticed eclipse gave other options besides null, which specify the names of my JPanels and so fourth and specify where on the screen the message will be displayed.And it is displayed perfectly,
Thank you,
RagamanLeave a comment:
-
JOptionPane in full screen mode??
Hello there,
I am designing a battleships game in java and am trying to output to the screen a simple message when a user sinks a ship. I have been trying to use JOptionPane to output a message, however it is not working correctly. The message is not being painted to the screen properly and the whole screen becomes inactive and i cant press any of the buttons on it. Any suggestions would be greatly appreciated??
Cheers,... -
Thank you for your advise, i have tried using this however but still to no success.I think the problem is i have to get a reference to the button pressed in the actionPerformed method, and then use the setIcon and setVisible methods.However when i refer to a button in the actionPerformed method it is not the same button as in the main method.I will post the code for the sound player class, you also need the pictures and sounds, i will try put these...Leave a comment:
-
Battleships game
Hello everyone,
I am currently working on a battleships game and at the moment i am playing around with a interface which has various different buttons. The interface has a 2d grid of buttons and other buttons on it which make various noises when pressed.I am however having problems changeing the icon of any of the buttons. Iv put up all the code of it, i am sorry for putting the whole thing up but thought maybe if i left some out someone... -
-
Battleships game
Hello everyone,
I am still working on my battleships project and have been doing some research into how i am going to implement it. I have been working with the idea of having a 2d grid of JButtons and have been looking into the graphics tutorials on the sun wesite but i have been advised that i would not need any of this (such as AlphaComposite) to display and change the display of the sea, ships etc. If so, does anyone have any ideas... -
Hello everyone,
I am still working on my battleships project and have been doing some research into how i am going to implement it. I have been working with the idea of having a 2d grid of JButtons and have been looking into the graphics tutorials on the sun wesite but i have been advised that i would not need any of this (such as AlphaComposite) to display and change the display of the sea, ships etc. If so, does anyone have any ideas...Leave a comment:
-
Thanks a million man, I appreciate it, i will give it a go.
Regards,
RagamanLeave a comment:
-
Battleships game
Hello there,
I have currently started a project in java, a battleships game. I am having trouble deciding how to deploy the grid and have the pictures of ships hidden under each picture of blue square which represents the sea. Can anybody out there give me some helpful pointers? Much appreciated,
thanks,
Ragaman
No activity results to display
Show More
Leave a comment: