Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI building

 
m dawg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I am creating a GUI, ok it is a JFrame that has a gamePanel that keeps all the object drawn on the screen like a drawing panel. Now i want to have a build mode and a run mode. when clicked on the build mode it draws a grid over the game panel and also it has buttons that you can click on to place the objects on the screen(square, circle...ect) in run mode the grid will go away and you can animate the ball. Im just looking for help and some code on how i would have this set up. if anyone can help i would really appreciate it. THANKS!!!
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already posted this once. How about showing what you have and we can give pointers.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have a few questions and then I may be able to help you.
1. Why do you need a grid?
2. Why are you placing shapes on the grid?
3. What will the ball do when it is animated?

------------------
Happy Coding,
Gregg Bolinger
 
m dawg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
I am doing it for fun. I want to learn java and how to make games. Thanks. I am trying to click on a button that is when i click on it and you can point and click on the grided screen and it paints that shape. How would i do that. Thanks
mdawg
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, why do you need a grid? And what does the ball have to do with anything. You aren't being very desriptive in your design goals.
If all you need is to place shapes on a screen, then I suggest using JLabels for you shapes. SWING does not support painting quite like AWT and you don't want to mix components. Just create a panel and add a mouselistener so when you click on the panel it adds a JLabel with an ImageIcon of your shape selected onto the panel.
I know this isn't very CODE descriptive. Let me see the code you have so far for this, and I will try and adjust it as necessary.
------------------
Happy Coding,
Gregg Bolinger
 
m dawg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't have anything just trying to get started. There doesn't need to be a ball. I just want to be able to: Here is what i need, i need to have a frame, that has a few buttons on it like two, square and circle. There will be a grid on the board where there images will click into place. They can be 10 across and 10 down 0-9 and each grided box is 30x30. So, when the user clicks on the button that has an imageIcon on it it paints that same imageIcon onto the gird. If you can help me out and get me started i would really appreciate it. Thank you so much. So, when the user clicks on the screen it will do nothing untill he click the button with the shape he wants to place on the grid. It needs to be a point then just click on the grid and panel and it will place that imageIcon, a gif or something. Thanks to all and Gregg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic