Results 1 to 8 of 8
  1. #1
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Question how to add an graphic or an image to a Jbutton?

    How to add a Graphic image to an Jbutton other than the Icon image......or is there any way to make Jbutton graphical like putting textures on it...????
    dk

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,870
    Rep Power
    8

    Default Re: how to add an graphic or an image to a Jbutton?

    What do you mean "other than the icon image"? What have you tried?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to add an graphic or an image to a Jbutton?

    button=new JButton(new IconImage(*.*));

    i have tried this code....but this code place a very small size pic on the JButton.
    but i want JButton to look more graphical like putting some texture graphics on it.
    dk

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,870
    Rep Power
    8

    Default Re: how to add an graphic or an image to a Jbutton?

    I recommend you give this a read: How to Use Buttons, Check Boxes, and Radio Buttons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    Then create an SSCCE that demonstrates exactly what you're trying, as well as maybe a mock-up of what your goal is.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to add an graphic or an image to a Jbutton?

    Solved...



    thanx so much for the help....
    dk

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,870
    Rep Power
    8

    Default Re: how to add an graphic or an image to a Jbutton?

    Quote Originally Posted by kumar.dinesh7 View Post
    Solved...



    thanx so much for the help....
    How did you solve it?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: how to add an graphic or an image to a Jbutton?

    Quote Originally Posted by KevinWorkman View Post
    How did you solve it?
    Now if he told us that, he would be making a positive contribution to the forum. You don't really expect that to happen, do you?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    kumar.dinesh7 is offline Member
    Join Date
    May 2012
    Location
    Yamuna Nagar,Haryana,India
    Posts
    28
    Rep Power
    0

    Default Re: how to add an graphic or an image to a Jbutton?

    as i posted earlier that i want to put some texture on the JButton...
    but if i put some texture on Jbutton using "button=new JButton(new IconImage(*.*));"
    it hides the Caption on jbutton...

    but by using "button.setHorizontalTextPosition(AbstractButton.C ENTER);"
    it will center the caption on Jbutton.

    now i can put any texture or any graphical image on JButton without hiding the caption.
    dk

Similar Threads

  1. JButton States Set to Pictures From Image Editor
    By wired-in=p in forum New To Java
    Replies: 10
    Last Post: 08-21-2011, 04:33 AM
  2. Replies: 7
    Last Post: 07-12-2011, 04:19 PM
  3. image on a JButton...how??
    By Habib in forum AWT / Swing
    Replies: 2
    Last Post: 02-27-2011, 06:56 PM
  4. changing JButton image upon clicking
    By Logical in forum AWT / Swing
    Replies: 2
    Last Post: 12-21-2010, 02:53 AM
  5. adding Image to JButton
    By mayhewj7 in forum New To Java
    Replies: 3
    Last Post: 03-31-2009, 03:39 AM

Posting Permissions

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