Need help with Layouts in Swing

Posted by Malki on Stack Overflow See other posts from Stack Overflow or by Malki
Published on 2010-04-12T13:24:47Z Indexed on 2010/04/12 15:53 UTC
Read the original article Hit count: 301

Filed under:
|
|

Hi,

I'm using Java Swing and I have the following problem:

I have a class TnaiPanel that extends JPanel. In this class I am creating 3 components and then lay them out in a horizontal line using a BoxLayout.

Also, I have a class TnaimDinamimPanel that also extends JPanel. This class contains multiple occurances of TnaiPanel, layed out vertically using a BoxLayout.

Also, I have a class MainFrame that extends JFrame. This frame contains a menu-bar and one main panel. The main panel can change (when choosing a certain menu-item, I create a new panel and set it to show as the main panel of the frame).

Now, for some reason I get "BoxLayout can't be shared" when I add the newly created TnaimDinamimPanel to the components of the frame.

I don't mind using different layout objects. The result I want to get is a sort of "table" of components, where each TnaiPanel will have fixed component sizes and spacing, essentially serving the role os a "row" in the "table".

Thanks, Malki.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing