images in buttons

Discussion in 'Java' started by patrick, Nov 11, 2003.

  1. patrick

    patrick Guest

    4 JButtons in a JPanel. Im trying to add .gif images so that the images are
    centered in the buttons.And will stay centered if the application is resized
    or the screen resolution is changed.
    How do I go about this?

    Do I make images Photoshop with the same pixel size as the buttons, or same
    inch dimensions (at some resolution)

    when the screen resolution is changed does the image get resized in
    proportion alsoalso?
    The JPanel will be Flow layout i think.


    patrick
    patrick, Nov 11, 2003
    #1
    1. Advertising

  2. On Tue, 11 Nov 2003 09:43:17 -0000, "patrick" <>
    wrote:

    >
    >
    >
    >4 JButtons in a JPanel. Im trying to add .gif images so that the images are
    >centered in the buttons.And will stay centered if the application is resized
    >or the screen resolution is changed.
    >How do I go about this?
    >


    create an Image from the gif :
    Toolkit.getDefaultToolkit().createImage(...)
    create an ImageIcon from the Image
    set the ImageIcon as the icon of your JButton
    see JButton properties to set how the icon will be placed in the JButton

    ciao
    --
    Seti@Home Java Applets
    http://maruko.webhop.net/
    Marco Parmeggiani, Nov 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger
    Replies:
    1
    Views:
    612
    GreggTB
    May 20, 2005
  2. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    432
    Teemu Keiski
    Jul 6, 2005
  3. Jeremy Jones

    Datagrid Nav buttons and numeric buttons

    Jeremy Jones, Mar 21, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    601
    Masudur
    Mar 22, 2007
  4. Jonathan N. Little
    Replies:
    3
    Views:
    511
    Andy Dingley
    Apr 2, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    279
    David Mark
    Oct 15, 2007
Loading...

Share This Page