Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Menu with Images?

  1. #1
    Junior Member Nuko32's Avatar
    Join Date
    Apr 2012
    Location
    Italy
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Menu with Images?

    Hi guys. Actually, I'm developing a stupid game in Java, like Space Invaders. I was wondering, how can I create a Menu (for the game, like "Play", "High Scores",etc.) with images?
    For example, if I have an image (the word "Play") and I want that when the user click on the image, the window with the game will open. Hope you have understood my problem. Please answer! Thanks in advance!
    Hacking is not a crime.


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    90
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: Menu with Images?

    I have not the answer but Space Invaders is a great game.So if you finish it,i would like to try it End of off topic post :p

  3. #3
    Junior Member Nuko32's Avatar
    Join Date
    Apr 2012
    Location
    Italy
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Menu with Images?

    LOL best answer ever!
    Hacking is not a crime.

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    90
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: Menu with Images?

    Quote Originally Posted by Nuko32 View Post
    Hi guys. Actually, I'm developing a stupid game in Java, like Space Invaders. I was wondering, how can I create a Menu (for the game, like "Play", "High Scores",etc.) with images?
    For example, if I have an image (the word "Play") and I want that when the user click on the image, the window with the game will open. Hope you have understood my problem. Please answer! Thanks in advance!
    I have netbeans.There you can choose to create a desktop applications.This will allow you to access methods such as an event.When user clicks on play for example this is considered to be an event.However i do not help you more with this :/

  5. The Following User Says Thank You to Samaras For This Useful Post:

    Nuko32 (August 1st, 2012)

  6. #5
    Member
    Join Date
    Jul 2012
    Posts
    69
    My Mood
    Relaxed
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default Re: Menu with Images?

    Depends how you make it. You could make a rectangle for each button, then whenever the mouse is pressed you could send the mouse pointer location to all your buttons. In your button you should check if it gets hit. In pseudo code:
    main.java
    ...
    ...
    if leftmousebuttonpressed
       for all buttons
           hit(mouse.x , mouse.y)
    ...
    ..
    button.java
     
    hit(mouse.x, mouse.y){
       new rectangle with mouse x and y size 1
       if mousrect.intersects button rect
          action()
    }
    Last edited by elamre; August 1st, 2012 at 11:24 AM. Reason: forgot the taggs

  7. #6
    Junior Member Nuko32's Avatar
    Join Date
    Apr 2012
    Location
    Italy
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Menu with Images?

    Thanks! I have solved the problem!
    Hacking is not a crime.

  8. #7
    Member
    Join Date
    Jul 2012
    Posts
    90
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: Menu with Images?

    Quote Originally Posted by Nuko32 View Post
    Thanks! I have solved the problem!
    By curiosity,how did you solve the problem?

Similar Threads

  1. Can anyone help me.. I cannot seem to get this menu looping
    By K1LL3R12 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 23rd, 2011, 08:23 AM
  2. Array and Menu
    By nitwit3 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 21st, 2011, 06:46 PM
  3. Is it possible to use card layout for menu and menu items?
    By jai2rul in forum AWT / Java Swing
    Replies: 0
    Last Post: April 11th, 2011, 08:19 AM
  4. popup menu
    By antonio69 in forum AWT / Java Swing
    Replies: 1
    Last Post: May 20th, 2010, 04:24 AM
  5. Help with Menu/BinSearch
    By jhar131 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 19th, 2010, 07:38 PM