String[] options = {"Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebante", "Cabaylo", "C. Cainglet", "O. Cainglet",
"Calunsag", "Cameros", "Casanaan", "Catulong", "Chicote", "Dela Paz", "Ea", "Echavez"};
int choose = JOptionPane.showOptionDialog(null, " WHICH EMPLOYEE'S DATA WOULD YOU LIKE TO RESET?", "Click to One Choose ", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null,
option, option[16]);
if(choose == 0)
{
JOptionPane.showMessageDialog(null, Ms. Adlawan is tall);
}
else if (choose == 1)
{
JOptionPane.showMessageDialog(null, Mr. Angeles is old);
}
这些是我上面的代码。它运行完美,如果我运行这些代码,将出现 17 个按钮,如果我单击由(选择 == 0)表示的“Adlawan”,则会出现消息(Adlawan 女士很高),如果我单击由(选择)表示的“Angeles” == 1) 出现消息(安吉利斯先生老了)。我遇到的问题是所有 17 个选项都不适合屏幕,我怎样才能使这 17 个选项按钮适合屏幕。我已经尝试过 JPanel 并将 JScrollPane 添加到面板并将这些选项按钮添加到面板但它不起作用。任何帮助将不胜感激。谢谢。