DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jul 2005

    JPanel with GridBagLayout resizing problem

    I created a JFrame that uses a GridBagLayout, with three JPanels inside. In one panel, which happens to be the largest, is a GridLayout of JButtons, in a 6x6 formation. The text for each of the JButtons changes periodically, and sometimes when it does change, there is a small change in the size of the whole Panel. My problem is that I can't find a way to keep the size of this JPanel from changing. I'm guessing it has something to do with the GridLayout wanting to keep all of the JButtons the same size, but when one of them changes (due to the change in its text), it forces them all to change so that they are equal in size. I tried looking for a way to prevent the size of the JButtons from changing, but I couldn't find anything. I also tried calling getBounds() every time the keyListener was active, before any change in text had occurred in the JButton, then I setBounds() to the bounds that I obtained before I changed the text... this didn't work.

    ANY suggestions?? Thanks!

  2. #2
    Join Date
    Aug 2003
    Try setting the Minimum, Maximum and Preferred sizes of the panel to the same thing. This should keep them from changing.

    Hope this helps.

Similar Threads

  1. CMR problem
    By vikassheelgupta in forum Java
    Replies: 0
    Last Post: 07-22-2005, 05:35 AM
  2. Problem with Search
    By Irina in forum ASP.NET
    Replies: 0
    Last Post: 11-29-2002, 10:47 PM
  3. Replies: 0
    Last Post: 12-13-2001, 12:06 PM
  4. JAVA help
    By Munchkin in forum Java
    Replies: 3
    Last Post: 03-16-2001, 04:58 PM
  5. Replies: 0
    Last Post: 06-23-2000, 02:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.