Results 1 to 7 of 7

Thread: Button

  1. #1
    Tb0h is offline Member
    Join Date
    Jul 2009
    Posts
    21
    Rep Power
    0

    Question Button

    Hello all,
    How do you make a button? I don't mean the default Java ones, but one designed by yourself. Do you make an animation or something of the three stages of the button? Also, how would I incorporate the coding for the button in the code below?
    Java Code:
    import java.applet.*; 
    import java.awt.*; 
                 
    public class BobRPG extends Applet{
      Image img;
      MediaTracker tr;
      public void paint(Graphics g) {
        tr = new MediaTracker(this);
        img = getImage(getCodeBase(), "example.gif");
        tr.addImage(img,0);
        g.drawImage(img, 90, 0, this);
      } 
    }
    I am trying to make it so the buttons appear below the "example.gif"
    Help appreciated!
    P.S. I wish to make this in an Applet

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    How do you make a button? I don't mean the default Java ones, but one designed by yourself.
    Myself, I'd create a JApplet to allow me to use Swing, and then would use a standard JButton but if I wanted it to have new images, I'd add the various ImageIcons to my button using the setIcon, setDisabledIcon, setPressedIcon,... methods.

    I'm a lazy programmer by nature, and so I'd try to avoid re-inventing the wheel when all the hard work's already been done for me.

    I am trying to make it so the buttons appear below the "example.gif"
    Again, if a JApplet, I'd place the image into a JLabel using an ImageIcon, and then would use one or more layout managers to place my JLabel and buttons so that the button(s) were below the image. BorderLayout comes immediately to mind.
    Last edited by Fubarable; 07-18-2009 at 09:26 PM.

  3. #3
    Tb0h is offline Member
    Join Date
    Jul 2009
    Posts
    21
    Rep Power
    0

    Default

    Could you tell me more about the various ImageIcons?
    Also, how would I place the image in a JLabel?
    (Sorry, I really don't know much about Java :p)

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Tb0h View Post
    Could you tell me more about the various ImageIcons?
    I would be glad to oblige. Please look here:
    How to Use Icons

    Also, how would I place the image in a JLabel?
    No problem!
    How to Use Labels

    (Sorry, I really don't know much about Java :p)
    Then why not feast at the table that's already laid out for you:
    Java Tutorials: The Really Big Index

    ¡Buen provecho!

  5. #5
    Tb0h is offline Member
    Join Date
    Jul 2009
    Posts
    21
    Rep Power
    0

    Default

    Thank you Fubarable, the links told me everything I need to know! Thank you!!! :):):)

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Wonderful! Glad it helped.

  7. #7
    Tb0h is offline Member
    Join Date
    Jul 2009
    Posts
    21
    Rep Power
    0

    Default

    I have another question... I made a thread called FreeWebs Applet and nobody has replied to it for 2 days now, while all the threads I have created before gain replies in a matter of an hour. Has it just been luck that my threads so far have gotten answers so quickly?

Similar Threads

  1. Button Functions
    By codeflip in forum New To Java
    Replies: 1
    Last Post: 03-12-2009, 03:26 AM
  2. Disabling a button at EOF
    By dbashby in forum New To Java
    Replies: 1
    Last Post: 03-10-2009, 03:37 PM
  3. Submit Button Help
    By Jay-1.1 in forum New To Java
    Replies: 2
    Last Post: 05-06-2008, 05:28 PM
  4. Using SWT Button
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 10:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •