Results 1 to 2 of 2
  1. #1
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default button not resizing in awt

    Hi

    I am adding a button to a panel with GridBagLayout


    I resize it using a Dimension object:

    Dimension dim = new Dimension(30,10);

    Button myButton = new Button();

    neither myButton.setSize(dim);
    nor myButton.setPreferredSize(dim);

    are working.... Not sure what else to do :mad:

  2. #2
    Maxideon is offline Member
    Join Date
    Jun 2010
    Posts
    28
    Rep Power
    0

    Default

    After you change the preferred size of an awt component you need to call invalidate() on it, and then call validate() on the frame containing the component.

    In swing this done automatically for you with a single revalidate() call. Although, technically swing doesn't travel all the way up to the frame to call validate(). It travels up to the the first component that returns true for JComponent#isValidateRoot.

Similar Threads

  1. panel resizing
    By simo_mon in forum AWT / Swing
    Replies: 1
    Last Post: 08-15-2009, 02:09 PM
  2. JFrame resizing
    By carderne in forum New To Java
    Replies: 3
    Last Post: 07-22-2009, 07:42 PM
  3. panel resizing
    By kumar_gemi in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 02:51 AM
  4. Image Resizing and DPi
    By Rob_ in forum Java Applets
    Replies: 4
    Last Post: 11-27-2008, 02:21 PM
  5. Image resizing
    By alley in forum Java 2D
    Replies: 2
    Last Post: 11-13-2007, 10:10 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
  •