Skip to main content
gamedev.net
🔒 Locked

[java] A dynamically added swing component will not draw

Started by kagey 0 replies 1.2k views
Original Post
kagey
kagey
hey all, here is my setup: I have a JPanel (j1) inside a JScrollPane. I am dynamically adding JPanels to j1, but they are not getting drawn right away. I have to force a relayout by resizing the window in order for the changes (added new JPanel) to j1 to be shown. If i call a doLayout() on j1 right after I add a JPanel (j2) to it, only the top level j2 elements are drawn (border, background) but not any children components (eg a label with text). If i resize the window, children components are drawn correctly. What gives? how can i force j2 to be displayed right away? TIA
kagey
kagey
nevermind, have to force a JScrollPane.revalidate().

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.