简体   繁体   中英

JTabbedPane aligning components

I have JTabbedPane with a few tabs. The problem i am facing is i have a panel which has 2 buttons inside it and a text area. the panel is inside a JScrollPane. I then add the JScrollPane to the tab, but the buttons and the text area are next to each other and are aligned in the center. What i want is the JTextArea to be under the buttons instead of being to the right of buttons. I have tried using BorderLayout for the buttons and text area (Putting buttons to page start and text area page end), but it doesn't change anything.

Panel.add(But1, BorderLayout.PAGE_START);
Panel.add(But2, BorderLayout.PAGE_START);
Panel.add(TextArea, BorderLayout.PAGE_END);
JScrollPane JSPane = new JScrollPane(Panel);
TabbedPanel.addTab("Tab name", JSPane);

Your issue might be with adding two buttons to the BorderLayout.PAGE_START. The second button will override the first button. A Visual Guide to Layout Managers , specifically the BorderLayout example should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM