I have done the code for Movie Ticket Booking and now I have stopped at JList
.
How to add data in JList
?
Here is a code...
JList listTime = new JList();
listTime.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listTime.setFont(new Font("Times New Roman", Font.PLAIN, 25));
listTime.setBounds(329, 311, 200, 50);
frame.getContentPane().add(listTime);
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/suhel","root","Suhel786");
Statement stmt = con.createStatement();
String sql="select distinct time from tbmovie where movie='"+select_mov+"'";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
listTime.add(rs.getString("time"));//here is the Error
}
}
catch(Exception e1){
System.out.print(e1);
}
I have retrieved data from database - only need is to add data in list.