java - Refresh code in browse button -
i working on user interface use browse button details of text files given. should display text file details on jtable , need refresh code in browse button of user interface. goes initial state of fetching data text files . using swing gui form-> jframe form. possible???
private void btnbrowseactionperformed(java.awt.event.actionevent evt) { jfilechooser j = new jfilechooser(); j.showopendialog(null); file f =j.getselectedfile(); string filename = f.getabsolutepath(); txtfile.settext(filename); //table.removeall(); try (bufferedreader br = new bufferedreader(new filereader(filename))) { string scurrentline; int count =1; table = new jtable(); defaulttablemodel tablemodel = new defaulttablemodel();{ while ((scurrentline = br.readline()) != null) { if(count==1) { if(tablemodel.getcolumncount()==0) { tablemodel.setcolumnidentifiers(scurrentline.split("\\t")); } } else { tablemodel.addrow(scurrentline.split("\\t")); //system.out.println(scurrentline); } count = count+1; } } table.setmodel(tablemodel); jscrollpane scrollpane = new jscrollpane(); scrollpane.setbounds(10, 42, 604, 195); scrollpane.setviewportview(table); panel.add(scrollpane);
Comments
Post a Comment