Guys this is really old and it's not a good practice anymore to avoid the keywords. Just name your functions and variables full readable names like "width", "height" or "resize".
Hey man I want to separate the logic from the GUI in two different packages but I´m having a rough time doing it cause once th code is done, once I run it it stops working right, could you help me with that plss?!
In the video Recursion and minesweeper ( java programming tutorial ) . I would like you to explain how the implementation of the blocks using JToggleButton because when you run appears the blocks occupying all the spaces next to each other.
The JToggleButtons are generated when you run the program. The code calculates the location and size of each button. That is not the best way actually. You should look into grid layout. That's the better way and it take less work
Hi, one question, wouldn't it be better to create a new class that extends the JToggleButton and then give our new button the functionalyti to return it's posisttion in the blocks array? Casue then we wouldn't need to sweep the hole array to findo out wich button we clicked on. Great video btw, keep up the god work !
Yeah that was not the best idea. You can actually to just store the JToggleButton inside a HashMap with the reference as the key and its index as the value.
It's really helpful thanks a lot about this. bro can i ask about the minesweeper java exercise. It's basically minesweeper but added the extra "treasure" grids. each grid now displays (a/b) in stead of (a). For minesweeper its the a is the amount of bombs nearby. But now for this exercise a is the amount of "treasure" nearby and b is the amount of bombs nearby. If u click on all treasure grids u win. U click on bomb grid u lose. Can you give me some ideas about this.
+Milano KT i think it will be the same. You technically just make 2 kinds of bombs and treat them the same but when user clicks on a treasure, he/she doesn't lose but earn some points
lol i get more bombs...should have been more specific im saying if you would create a new menu beside game or something and called it difficulty or what not then you had 3 menu items for 3 types of difficulty how would you get that to function without having to write a lot more code since you already have wei and hei defined as 10 and 10 and bombs at 10 and at least 2 of the methods wouldn't work when you called them under another menu item like for open and spawn
i was trying that just testing some stuff out with your code and i couldnt get it to remake the board for some reason not sure what i was doing wrong ill play around with it a bit
like remake as in instead of 9/9 i was trying to remake it under another menu item with 20/20 with whatever amount of bombs but it was doing weird shit im still messing with it
thnx alot for the game codes! it helped me with my project. But i happened to see one problem. I inserted pictures of the bomb to the blocks and it works perfectly fine however, if supposedly we did press on a mine and click new game, the pictures of the mine remains visible. what codes do i put in menu option to avoid this?
I think I answered it in one of the comment. I'm just going to copy and paste it here. just drag the image into the source code folder/package and to show the image on the button you can use: button.setIcon(new ImageIcon(getClass().getResource("mine-xp.gif"))); mine-xp.gif is the name of the image. You should use either gif or png image to preserve the transparency of the background
Guys this is really old and it's not a good practice anymore to avoid the keywords. Just name your functions and variables full readable names like "width", "height" or "resize".
Thank you! I had a uni assignment with a similar minesweeper program, and I was really struggling with implementing recursion. Finally figured it out!
Hey man I want to separate the logic from the GUI in two different packages but I´m having a rough time doing it cause once th code is done, once I run it it stops working right, could you help me with that plss?!
In the video Recursion and minesweeper ( java programming tutorial ) . I would like you to explain how the implementation of the blocks using JToggleButton because when you run appears the blocks occupying all the spaces next to each other.
The JToggleButtons are generated when you run the program. The code calculates the location and size of each button. That is not the best way actually. You should look into grid layout. That's the better way and it take less work
Hi, one question, wouldn't it be better to create a new class that extends the JToggleButton and then give our new button the functionalyti to return it's posisttion in the blocks array?
Casue then we wouldn't need to sweep the hole array to findo out wich button we clicked on. Great video btw, keep up the god work !
Yeah that was not the best idea. You can actually to just store the JToggleButton inside a HashMap with the reference as the key and its index as the value.
It's really helpful thanks a lot about this.
bro can i ask about the minesweeper java exercise.
It's basically minesweeper but added the extra "treasure" grids.
each grid now displays (a/b) in stead of (a). For minesweeper its the a is the amount of bombs nearby. But now for this exercise a is the amount of "treasure" nearby and b is the amount of bombs nearby. If u click on all treasure grids u win. U click on bomb grid u lose.
Can you give me some ideas about this.
+Milano KT i think it will be the same. You technically just make 2 kinds of bombs and treat them the same but when user clicks on a treasure, he/she doesn't lose but earn some points
did you create a method for jPanell when you used it at 22.26
dw realised it was a 1 and not another l
getWidth() and getHeight() are built-in jpanel methods.
How would you go about adding difficulty into this though?
More bombs :D
lol i get more bombs...should have been more specific im saying if you would create a new menu beside game or something and called it difficulty or what not then you had 3 menu items for 3 types of difficulty how would you get that to function without having to write a lot more code since you already have wei and hei defined as 10 and 10 and bombs at 10 and at least 2 of the methods wouldn't work when you called them under another menu item like for open and spawn
Geo stalker you can change those variables before you generate the board.
i was trying that just testing some stuff out with your code and i couldnt get it to remake the board for some reason not sure what i was doing wrong ill play around with it a bit
like remake as in instead of 9/9 i was trying to remake it under another menu item with 20/20
with whatever amount of bombs but it was doing weird shit im still messing with it
thnx alot for the game codes! it helped me with my project. But i happened to see one problem. I inserted pictures of the bomb to the blocks and it works perfectly fine however, if supposedly we did press on a mine and click new game, the pictures of the mine remains visible. what codes do i put in menu option to avoid this?
+December Blue just loop through the buttons and remove the pictures.
can i have your source code?
pleaseee
Isn't it in the description?
Jack Le I figured it out. I don't know how to put icons in the bomb spaces though and I'm new to java too
I think I answered it in one of the comment. I'm just going to copy and paste it here.
just drag the image into the source code folder/package and to show the image on the button you can use:
button.setIcon(new ImageIcon(getClass().getResource("mine-xp.gif")));
mine-xp.gif is the name of the image. You should use either gif or png image to preserve the transparency of the background
Jack Le thank youuuu