How to make pairs of strings that are contained in a list and display each string in columns of jTable? [Java Swing] -
i creating game registration , matchmaking system. able register people in mysql database. can name values in database column list , shuffle it. want strings in list display alternately in jtable has 2 columns. example: have james, harry, ali, sinclair, bob in list. shuffle it. want display in jtable like: column 1 contains james, column 2 contains harry, again column 1 contains ali , column 2 contains sinclair. that. hope have been clear. have tried:
list<string> names = new arraylist<string>(); string category = (string) jcombobox1.getselecteditem(); try { resultset rs = dbc.getdata("select * main c_category='" + category + "'"); while(rs.next()){ names.add(rs.getstring("c_name")); } } catch (exception ex) { logger.getlogger(matchmake.class.getname()).log(level.severe, null, ex); } system.out.println(names); collections.shuffle(names); system.out.println(names); defaulttablemodel dtm = (defaulttablemodel) jtable1.getmodel(); dtm.addrow(new object[]{names}); but doesnt give desired result. ideas? thanks.
Comments
Post a Comment