Results 1 to 6 of 6
  1. #1
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default My icon extends my JButton

    I attached an icon to my JButton. When my JButton is shrinked, my icon shrinks (and finally disappears)as well. What should I do to ensure that the button will wrap around the icon?

    Note that the picture shows my button with the icon.
    Attached Thumbnails Attached Thumbnails My icon extends my JButton-untitled.jpg  

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Try setting preferred and minimum size on the button.

  3. #3
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    I tried. it shrinks my button AND my icon as well. not what I want.

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    What shrinks them? I assume you are setting the values to at least the size of the image...

    If your image is too large to start with, use a editing tool and scale it down.

  5. #5
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    I scaled my image down already. It can be seen in my diagram. But when the button is shrink, the icon also shrink. The icon never fits the button!

  6. #6
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Well you can try to place an image to your button with java2D. Maybe it is your JRE problems (
    Maybe the icon you want to add for your button is too large. Try to make it smaller and try again )

Similar Threads

  1. Replies: 4
    Last Post: 02-13-2009, 08:42 AM
  2. set.Icon
    By safiya in forum NetBeans
    Replies: 2
    Last Post: 10-17-2008, 07:46 PM
  3. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 11:48 AM
  4. icon
    By amith in forum AWT / Swing
    Replies: 1
    Last Post: 05-16-2008, 08:34 PM
  5. Implements MyClass extends JFrame
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 04:43 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
  •