您好我想在jscrollpane中的jList中添加记录列表,请各位帮帮我
班级Values
:
public static JList<String> indicesJList;
indicesJList = new JList<String>();
indicesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
indicesJList.setLayoutOrientation(JList.VERTICAL);
indicesJList.setVisibleRowCount(-1);
listScroller = new JScrollPane(**indicesJList**,ScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
班级Database
:
public static void GetUSMarket() throws SQLException {
java.sql.Connection con = DriverManager.getConnection(url + dbName, userName, password);
PreparedStatement ps = con.prepareStatement("SELECT Company FROM tbindices WHERE Continent = ('North America')");
ResultSet result = ps.executeQuery();
if (result != null) {
while (result.next())
{
Values.indicesJList.add("company"); // here I have an error
}
}
ps.close();
con.close();
}
}