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);
精彩评论