Java 为JPanel定制宽度和高度

Java 为JPanel定制宽度和高度,java,swing,jpanel,layout-manager,Java,Swing,Jpanel,Layout Manager,为什么我的JPanel在我尝试调整大小到我想要的大小时,会散布到框架的其余部分 这是代码片段 public class GUITabbedPane extends JFrame{ TabsPanelClasses tabPanel = new TabsPanelClasses(); public GUITabbedPane() { TabsPanelClasses.CreateAccount createAccount = tabPanel.new CreateAccount();

为什么我的JPanel在我尝试调整大小到我想要的大小时,会散布到框架的其余部分

这是代码片段

public class GUITabbedPane extends JFrame{

TabsPanelClasses tabPanel = new TabsPanelClasses();
public GUITabbedPane()
{
    TabsPanelClasses.CreateAccount createAccount = tabPanel.new  CreateAccount();
    TabsPanelClasses.BorrowBook borrowBook = tabPanel.new  BorrowBook();

    JTabbedPane tabs = new JTabbedPane(JTabbedPane.LEFT);

    //Tab text support html tags
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Create Account</body></html>", null,createAccount.createAccountPanel(),"New Member Account");
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Borrow Book</body></html>", null,borrowBook.borrowBookInputs(),"Borrowing a book");
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Return Book</body></html>", null,null,"Returning a book");
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Add Book</body></html>", null,null,"Adding a book record");
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Delete Book</body></html>", null,null,"Deleting a book record");
    tabs.addTab("<html><body marginwidth=30 marginheight=20>Display Details</body></html>", null,null,"Books and Members details");

    add(tabs);
    pack();

}
public static void main(String[] args) {
    GUITabbedPane frame = new GUITabbedPane();

    frame.setDefaultLookAndFeelDecorated(true);
    frame.setSize(800, 400);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

}

同时设置框架的布局:

frame.setLayout(LayoutManager);

为了更快地获得更好的帮助,请发布一个.mu问题,非常适合您!我的答案正在等待SSCCE。是的,现在我的帖子是SSCCE!SSCCE只能有一个
public
类。您(错误地)认为哪个代码是SSCCE?
frame.setLayout(LayoutManager);