.............................
Printable View
.............................
I have no idea what you mean by: "appear that row on the next run". Can you explain what is happening because I am unclear.Quote:
While the user checked the checkbox, it will not appear that row on the next Run.
............................
Code java:class StockEnquiryStaff implements Comparable { public String name; public String telephone; public String callback; public String enquiry; public Boolean check; public StockEnquiryStaff(String n, String t, String c, String e, Boolean ck){ this.name = n; this.telephone = t; this.callback = c; this.enquiry = e; this.check = ck; } public String getName() { return name; } public String getTelephone() { return telephone; } public String getCallback() { return callback; } public String getEnquiry() { return enquiry; } public Boolean getCheck() { return check; } public int compareTo(Object o) { StockEnquiryStaff temp = (StockEnquiryStaff) o; return (callback.compareTo(temp.callback)); } } --------------------------------------------------------------------------------------- //This is how i set the column 5 to become a checkbox class ATableClass extends JTable { public Class getColumnClass(int column) { try { if (column == 4) { return Class.forName("java.lang.Boolean"); } return Class.forName("java.lang.Object"); } catch (ClassNotFoundException ex) { ex.printStackTrace(); return null; } } } ---------------------------------------------------------------------------- //This is the Stock Enquiry class which contain Jtable, button, text field and Jlabel. public class StockEnquiryStaffView extends JFrame { // A container for the Product instances ArrayList StockEnquiriesStaff = new ArrayList(); // StockEnquiryStaffView bits and bobs JPanel panInput = new JPanel(new GridLayout(4,20)), panAdd = new JPanel(), panDelSort = new JPanel(); JTextField txtName = new JTextField(10), txtTelephone = new JTextField(10), txtCallback = new JTextField(5), txtEnquiry = new JTextField(20); JButton btnAdd = new JButton("Add"), btnDelete = new JButton("Delete"), btnSort = new JButton("Sort Callback Time by Ascending"), btnSort1 = new JButton("Sort Callback Time by Descending"), btnSave = new JButton("Save"); ATableClass tableOne = new ATableClass(); DefaultTableModel tabMod = new DefaultTableModel(); //This is the read file method which read from text file and using the loadProductsIntoTable //to load all the data into the JTable. public void readfile() throws IOException { BufferedReader br = new BufferedReader( new FileReader("salesEnquiryLog.txt")); String s; String getName = ""; String getTelephone = ""; String getCallback = ""; String getEnquiry = ""; Boolean getCheck = null; int i = 0; while((s = br.readLine()) != null) { if (s.equals("<sales_enquiry>")) { getName = br.readLine(); getTelephone = br.readLine(); getCallback = br.readLine(); getEnquiry = br.readLine(); StockEnquiryStaff [] StockEnquiries = {new StockEnquiryStaff(getName, getTelephone,getCallback,getEnquiry, getCheck)}; StockEnquiriesStaff.add(StockEnquiries[i]); loadProductsIntoTable(); } } } // This is the method of load all the data in the product array into the JTable (row by row). public void loadProductsIntoTable() { tabMod.setRowCount(0); String [] row = new String [4]; for (Iterator i = StockEnquiriesStaff.iterator(); i.hasNext() { StockEnquiryStaff temp = (StockEnquiryStaff) i.next(); row[0] = temp.getName(); row[1] = temp.getTelephone(); row[2] = temp.getCallback(); row[3] = temp.getEnquiry(); tabMod.addRow(row); } } //Stock Enquiry public StockEnquiryStaffView() throws IOException { super("Stock Enquiry Staff View"); tableOne.setModel(tabMod); tabMod.addColumn("Manager Name"); tabMod.addColumn("Telephone"); tabMod.addColumn("Callback Time"); tabMod.addColumn("Enquiry"); tabMod.addColumn("Check"); // All the btn, txt, jlabel here ------------------------------------------------------------------------------------------
Looks like it's reading a name, a number, and a time.
....................