我正在努力使我的 JPanel 更大。我有三个选项卡,但是当我运行程序时,并非所有选项卡都显示(除非我单击箭头)。我只需要知道如何使面板更大,这样我就不必单击箭头
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
public class TestApplication {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(1000, 1000);
frame.setTitle("RBA Test Application");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JButton initialize = new JButton("Initialize");
JButton connect = new JButton("Connect");
JButton disconnect = new JButton("Disconnect");
JButton shutdown = new JButton("Shut Down");
JButton portsettings = new JButton("Port Settings");
JPanel buttonPanel = new JPanel();
buttonPanel.add(initialize);
buttonPanel.add(connect);
buttonPanel.add(disconnect);
buttonPanel.add(shutdown);
buttonPanel.add(portsettings);
frame.add(buttonPanel);
frame.add(buttonPanel, BorderLayout.NORTH);
frame.pack();
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("LLP", null, null, "Low Level Protocol");
tabbedPane.addTab("POS",null, null, "Point Of Sale");
tabbedPane.addTab("Test", null, null, "Test");
JPanel tabsPanel = new JPanel();
tabsPanel.add(tabbedPane);
frame.add(tabsPanel);
tabsPanel.setPreferredSize(new Dimension(900, 900));
frame.add(tabsPanel, BorderLayout.CENTER);
frame.pack();
}
}