为什么在创建 JComboBox 对象时会出现此编译错误?
Why do i get this compilation error in creating JComboBox object?
Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
System.out.println("Connected database successfully...");
PreparedStatement ps = con.prepareStatement( "select * from web");
ResultSet rs = ps.executeQuery();
ArrayList<String> v = new ArrayList<>();
while ( rs.next()) {
String s = rs.getString(1);
v.add(s);
}
bx = new JComboBox(v);
bx.setBounds(150, 20, 200, 20);
f.add(bx);
}
我收到以下编译错误“构造函数 JComboBox(ArrayList) 未定义 ”
你快到了!!
JCombobox 将参数作为字符串数组。您将不得不转换它或手动添加它
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
System.out.println("Connected database successfully...");
PreparedStatement ps = con.prepareStatement( "select * from web");
ResultSet rs = ps.executeQuery();
bx = new JComboBox();
while ( rs.next())
{
String s = rs.getString(1);
bx.addItem(s);
}
bx.setBounds(150, 20, 200, 20);
f.add(bx);
}
Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
System.out.println("Connected database successfully...");
PreparedStatement ps = con.prepareStatement( "select * from web");
ResultSet rs = ps.executeQuery();
ArrayList<String> v = new ArrayList<>();
while ( rs.next()) {
String s = rs.getString(1);
v.add(s);
}
bx = new JComboBox(v);
bx.setBounds(150, 20, 200, 20);
f.add(bx);
}
我收到以下编译错误“构造函数 JComboBox(ArrayList
你快到了!! JCombobox 将参数作为字符串数组。您将不得不转换它或手动添加它
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
System.out.println("Connected database successfully...");
PreparedStatement ps = con.prepareStatement( "select * from web");
ResultSet rs = ps.executeQuery();
bx = new JComboBox();
while ( rs.next())
{
String s = rs.getString(1);
bx.addItem(s);
}
bx.setBounds(150, 20, 200, 20);
f.add(bx);
}