java - Adding data to jTable from Database (via Netbeans) no errors, but table disappears -
Debugging data is somehow retrieved completely and result models actually get column names, and for rows Although data was compiled in netbeans after the search and ran, the table disappeared, no data column names were also shown. Here's the code:
Private zero search () {string [] [] rowData = new string [0] [4]; String [] column = {"appointment", "FNGEG", "label", "registration", "make", "model", "engine", "year", "mileage", "type", "date" Time"}; ResultsModel = New DefaultTel Model (Line Data, Column); Addition (new JScrollPane (jTable1)); JTable1 = new JTable (resultModel); JTable1.setAutoCreateRowSorter (true); {Model_Customer [] Appointment = Controller_Advertisement Client. Try Customer (SearchText.gettext ()); ResultModel.setRowCount (0); (Int i = 0; I & Lt; Appointment; Length; I ++) ResultsModel.InstoRo (i, New Object [] [Appointment [i] .GateID (), Appointment [i] .GETFName (), Appointment [i Appointment [i] .GetMegel (), Appointment [i] .GetMake (), Appointment [i] .GetModel (), Appointment [i] .GetEngine (), Appointment [i] .GetYear (), Appointment [I ] .GetMileage (), Appointment [i] .Gettype (), Appointment [i] .Geteted (), Appointment [i]. GateTime ()}); } Hold (Exception pre) {JOptionPane.showMessageDialog (this, former .getMessage (), "Error", JOptionPane.ERROR_MESSAGE); }} DefaultTableModel ResultsModel
It may just be me ... but it is very doubtful Looks like ...
(New JScrollPane (jTable1)); JTable1 = new JTable (resultModel); To not mention
, you can go to a new creation and good new DefaultTableModel
but not really implemented for doing anything on the screen. Are there.
Try something else ...
resultsModel = new defaulttel model (row data, column); {Model_Customer [] Appointment = Controller_Advertisement Client. Try Customer (SearchText.gettext ()); ResultModel.setRowCount (0); (Int i = 0; I & Lt; Appointment length; I ++) {ResultsModel.IndroRo (i, new object [] [appointment [i] .GateID (), appointment [i] .GETFName (), appointment [ I] Appointments [i] .GetMegel (), Appointment [i] .GetMegel (), Appointment [i] .GetEngine (), Appointment [i] .GetYear (), Appointment [i]. [I]. ), Appointment [i] .GetType (), Appointment [i]. Gateet (), Appointment [i]. GateTime ()}); } If (jTable1 == faucet) {jTable1 = new JTable (resultModel); Addition (new JScrollPane (jTable1)); } And {jTable1.setModel (resultModel); }} Hold (exception before) {JOptionPane.showMessageDialog (this, ex.getMessage (), "error", JOHNPIONPAN.ArroR_MMSEG); }
Now, personally, I will just create JTable
and add it to the screen, and leave it alone, and just TableModel
Whenever you wanted to update its content ...
Swing uses a form of paradigm, which means it separates the scene from the model, which means that when you If you want to change this, then showing jibbles
(view), you simply change the model ...
Comments
Post a Comment