对于我的 UI,我让用户从三个下拉框中做出三个选择。我一直无法弄清楚是否有一种方法可以三合一JPanel
。到目前为止,我只有三个不同的JPanels
. 如何将所有三个投递箱添加到一个JPanel
?
这是我的代码
JPanel panel = new JPanel();
panel.add(new JLabel("Please select a country:"));
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement("Great Britian");
model.addElement("United States");
JComboBox comboBox = new JComboBox(model);
panel.add(comboBox);
JOptionPane.showConfirmDialog(null, panel, "Country",
JOptionPane.OK_OPTION,
JOptionPane.QUESTION_MESSAGE);
JPanel panel1 = new JPanel();
panel1.add(new JLabel("Please select a restaurant category"));
DefaultComboBoxModel model1 = new DefaultComboBoxModel();
model1.addElement("Diner");
model1.addElement("Evening Only");
model1.addElement("All day");
JComboBox comboBox1 = new JComboBox(model1);
panel1.add(comboBox1);
JOptionPane.showConfirmDialog(null, panel1,
"Restaurant",
JOptionPane.OK_OPTION,
JOptionPane.QUESTION_MESSAGE);