每次运行程序时,我都会收到一条错误消息。这是我的代码的一小部分:
JFrame f; JPanel p1;
int i=0, m=0;
int[] subbb = {0,1,2,3};
String[] status = {"Add", "Repeat"};
String[] comboStat = {"combo_status1", "combo_status2","combo_status3", "combo_status4"};
JComboBox combo_status1, combo_status2, combo_status3, combo_status4;
JComboBox combo_set_panel = new new JComboBox(subbb);
combo_status1=new JComboBox(status); combo_status2=new JComboBox(status);
combo_status3=new JComboBox(status); combo_status4=new JComboBox(status);
for(i=0; i<4; i++) {
if (combo_set_panel.getSelectedIndex() == subbb[i]) {
for(m=0; m<=subbb[i]; m++)
{
p1.add(comboStat[m]); //Error Message Shows This Line
}
}
}
f.add(p1);
但是,在运行这个程序时。我收到此错误消息:
Add a String: error: no suitable method found for add(String)
任何人请告诉我此错误的解决方案。适合的方法是add(String)
什么?