Results 1 to 3 of 3

Thread: Jbutton size

  1. #1
    mrvigneshmca is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default Jbutton size

    hi friends.
    I am new to swings. I am using buttons in my panels. I want to resize the button according to my requirement. I used setPreferredSize() but this method only alters buttons width and not height.Can u help me overcome this hurdle.The question may be simple but still i need a precise solution pls

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Rep Power


    What do you mean "resize the button according to my requirement".

    Normally the button is as large as it needs to be to display what it needs to display.

    Try, however, changing not only setPreferredSize, but setMinimumSize as well, then, of course, validate and repaint the Panel containing the button.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    What layouts are you using for the container that holds your button? A small bit of formatted code with code tags would go a long way towards clarifying your question. Thanks.

Similar Threads

  1. Jbutton not working??
    By rmabrey in forum AWT / Swing
    Replies: 7
    Last Post: 09-24-2008, 05:30 PM
  2. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 10:48 AM
  3. JButton onClick?
    By Joe2003 in forum AWT / Swing
    Replies: 2
    Last Post: 01-06-2008, 04:04 PM
  4. Help with JButton and layout
    By adlb1300 in forum AWT / Swing
    Replies: 1
    Last Post: 12-25-2007, 09:33 AM
  5. Need help with JButton event
    By adlb1300 in forum New To Java
    Replies: 2
    Last Post: 11-19-2007, 02:15 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