开发者

jgoodies how to remove component added with PanelBuilder?

开发者 https://www.devze.com 2023-01-08 06:48 出处:网络
I am using com.jgoodies.forms.builder.PanelBuilder to add Buttons and rows. Then I call PanelBuilder.getPanel() and attach the panel to a JPopupMenu.

I am using com.jgoodies.forms.builder.PanelBuilder to add Buttons and rows. Then I call PanelBuilder.getPanel() and attach the panel to a JPopupMenu.

Is there a way to remove and reattach some of the attached components from the Panel that PanelBuilder has produced: I want to blend in/out one of the attached Buttons dynamically and the corresponding empty row (added 开发者_C百科with PanelBuilder.appendRow("f:30px")).

Thanks.


Removing the component does work but it leaves area of unused space on the panel. JPanel.revalidate() works only when PanelBuilder.appendRow() was not used before adding JButton.

Also, I couldn't reattach removed JButton. It appears in the component list of JPanel but is not being displayed.

That's why I went to create a new JPanel dynamically on every request and assigning it to the JPopupMenu.


If you have ketp references to the initial item, there is nothing that prevents you from doing a

myPanel.remove(theComponent);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号