java - read binary file and display content in Jlist -
how can read binary file , display in jpanel.up have initialized jframe,jpanel jbutton when run code button , frame appears when click show button need show data file here code have done.
public class graphicaldisplay{ private jframe cframe; private jbutton showbutton; public graphicaldisplay() { } public void displaycompanylist() { //creating frame display of contents , containers , other elements jlabel , jbutton cframe = new jframe("list of companies"); cframe.setlocation(700,150); cframe.setsize(600,300); //creating button showbutton =new jbutton("show list"); //create panel hold button jpanel bpanel=new jpanel(); bpanel.add(showbutton); //add panel frame cframe.add(bpanel,borderlayout.center); cframe.setvisible(true); showbutton.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent ae) { byte [] buffer =null; file a_file = new file("companies.dat"); try { fileinputstream fis = new fileinputstream("companies.dat"); int length = (int)a_file.length(); buffer = new byte [length]; fis.read(buffer); fis.close(); } catch(ioexception e) { e.printstacktrace(); } } }); } }
Comments
Post a Comment