Problem with GridBagLayout and ComboBox

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Problem with GridBagLayout and ComboBox

Postby mkornatzki » Fri Aug 20, 2010 12:54 am


under the following condition
* layout=GridBagLayout
* cell with JCombobox
* vertical grow
* anchor = GridBagConstraints.BASELINE <- this causes the problem

i get the error
Code: Select all
java.lang.IllegalArgumentException: Width and height must be >= 0

Code: Select all
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[]{0, 0};
gbl_contentPane.rowHeights = new int[]{0, 0};
gbl_contentPane.columnWeights = new double[]{0.0, Double.MIN_VALUE};
gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
GridBagConstraints gbc_cmb = new GridBagConstraints();
gbc_cmb.anchor = GridBagConstraints.BASELINE;
gbc_cmb.fill = GridBagConstraints.HORIZONTAL;
gbc_cmb.gridx = 0;
gbc_cmb.gridy = 0;
contentPane.add(getCmb_1(), gbc_cmb);

cheers, michael
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Problem with GridBagLayout and ComboBox

Postby Eric Clayberg » Sat Aug 21, 2010 5:17 am

This is caused by a bug in Swing.

We have added a work around in the latest build.
Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest