我创建了一个带有jframe和contentpanel的gui。这个contentpanel是我的gui的一个方面。我现在决定要进一步开发这个gui,并在其中包含一个jtabbedpanel。我希望当前显示的contentpanel是jtabbedpane中的选项卡之一。
基本上,我想要我的jframe和一个具有jtabbedpane的jpanel,并且在这些选项卡中我想要放置jpanel。我还在当前显示gui的jpanel上使用gridbaglayout,这使得一切变得困难。
有人请帮忙。下面是一些截图。当前gui截图我希望它是这样的
下面是我的gui代码:``java
公共gui(){
loadRegPlateArray();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(500, 200, 1000, 600);
contentPane = new JPanel();
contentPane.setBackground(Color.BLACK);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[]{0, 131, 160, 114, 16, 117, 147, 246, 0};
gbl_contentPane.rowHeights = new int[]{0, 75, 56, 50, 61, 55, 69, 56, 40, 40, 10, 0};
gbl_contentPane.columnWeights = new double[]{1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_contentPane.rowWeights = new double[]{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
contentPane.setLayout(gbl_contentPane);
JComboBox comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(cl.regArray));
GridBagConstraints gbc_comboBox = new GridBagConstraints();
gbc_comboBox.insets = new Insets(0, 0, 5, 5);
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
gbc_comboBox.gridx = 2;
gbc_comboBox.gridy = 1;
contentPane.add(comboBox, gbc_comboBox);
JButton btnNewButton = new JButton("Add new car");
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
gbc_btnNewButton.gridx = 3;
gbc_btnNewButton.gridy = 1;
contentPane.add(btnNewButton, gbc_btnNewButton);
rest of the content of the gui (jlabels etc)
Thank you!
暂无答案!
目前还没有任何答案,快来回答吧!