Skip to main content



      Home
Home » Eclipse Projects » WindowBuilder » Cannot change inherited controls(A child panel cannot change inherited (protected or public) widgets.)
Cannot change inherited controls [message #1062484] Fri, 07 June 2013 23:23 Go to next message
Eclipse UserFriend
I created a panel (using JGoodies Form Layout) and the child class cannot add other widgets to it. When I try to add the widget manually (by code), WindowBuilder raises a NullPointerException. Please take a look in the attached file.
Re: Cannot change inherited controls [message #1062559 is a reply to message #1062484] Sat, 08 June 2013 20:55 Go to previous messageGo to next message
Eclipse UserFriend
Actually, the exception is being raised by the FormLayout itself (not by WindowBuilder) because the example code is violating a constraint. The example code throws the following exception:

java.lang.IndexOutOfBoundsException: The column index 7 must be less than or equal to 5.
at com.jgoodies.forms.layout.CellConstraints.ensureValidGridBounds(CellConstraints.java:935)
at com.jgoodies.forms.layout.FormLayout.setConstraints(FormLayout.java:826)
at com.jgoodies.forms.layout.FormLayout.addLayoutComponent(FormLayout.java:1103)

It appears you are trying to add a widget to the 7th column of a 5 column grid. That won't work. You can add inherited controls, but they can't violate the column spec defined in the parent. If I add an extra column to the parent class in your example, it then works fine whether I add the widget manually or through the editor.

[Updated on: Sat, 08 June 2013 20:55] by Moderator

Re: Cannot change inherited controls [message #1062562 is a reply to message #1062559] Sat, 08 June 2013 21:18 Go to previous messageGo to next message
Eclipse UserFriend
OK. Many thanks, Eric. It is strange because when I try to add a component (like a button), it can't be placed in the parent's cell. I thought I could add columns/rows and add new components in the child class, like I used to do in other GUI frameworks, like Borland ones. So it is a constraint, right? Swing behaves a little bit different than I thought...

[Updated on: Sat, 08 June 2013 21:25] by Moderator

Re: Cannot change inherited controls [message #1062563 is a reply to message #1062562] Sat, 08 June 2013 21:36 Go to previous messageGo to next message
Eclipse UserFriend
You can add children in the child, but they have to be placed in a cell defined in the parent. If the parent class defines a 5x1 grid, you won't be able to add a widget at the 7x1 location. Enlarging the gird in the parent will allow you to add the extra widget in the child. This is a JGFL issue rather than a generic Swing issue. The grid is defined in the parent, so the constraint is set there.
Re: Cannot change inherited controls [message #1062564 is a reply to message #1062563] Sat, 08 June 2013 21:54 Go to previous messageGo to next message
Eclipse UserFriend
I also can't add new columns/rows in the child, right? (I need to define everything in the parent).

WindowBuilder shows a "java.lang.ClassCastException: org.eclipse.wb.internal.swing.model.layout.ImplicitLayoutCreationSupport cannot be cast to org.eclipse.wb.internal.core.model.creation.ConstructorCreationSupport"
message when I try to do this.

Maybe it would be better (if possible) show better messages depending on the context. Just to make it easier to understand.

Thank you.


[Updated on: Sat, 08 June 2013 22:04] by Moderator

Re: Cannot change inherited controls [message #1062583 is a reply to message #1062564] Sun, 09 June 2013 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Right. You can't alter the constraints set up in the parent. You need to define the number of rows and columns that you need in the parent and then you can add widgets to that grid in the child.

For what you are doing, GridBagLayout would be a much, much better choice. In that layout, the grid is built p implicitly based on where you place the children, so you can easily add new widgets pretty much anywhere you like.

For creating a row of buttons in the parent and then adding extra buttons in the child, the standard Swing GridLayout would also be a better choice.
Re: Cannot change inherited controls [message #1062603 is a reply to message #1062583] Sun, 09 June 2013 17:14 Go to previous message
Eclipse UserFriend
Good point. I'll follow your suggestions. Thanks, Eric.
Previous Topic:GEF Components
Next Topic:XML databinding in SWT help
Goto Forum:
  


Current Time: Tue Jul 01 18:29:17 EDT 2025

Powered by FUDForum. Page generated in 0.02407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top