开发者

Inserting Items to BoxLayout at Runtime?

I am trying to figure out how I can insert items to BoxLayout at runtime... or achieve a similar effe开发者_StackOverflowct using a different widget/panel/layout.

The design for the application window is to have several panels stacked vertically (BoxLayout.Y_AXIS). The user can then insert or delete panels, as well as interact with any widgets that are inside the panel. My hope would be to bind this to an observable list, where classes representing each panel type are inserted and the UI is updated accordingly.

Thank you for any pointers!


javax.swing.SwingUtilities will allow you to perform operation in the event dispatcher thread (EDT) - all operations that update UI must be performed in EDT. Also don't hesitate to call, revalidate() and repaint() methods after you added your components on the container you're adding components to, that will allow parent component to recalculate positions of all elements (including new ones), and redraw itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜