swing - How to add and delete table in java -


i have code making table , sort data input there. if want add action using button add row fill data , can delete row too. here code:

public class tablesortdemo extends jpanel {     private boolean debug = false;      class mytablemodel extends abstracttablemodel {         private string[] columnnames = {"nama",                                         "nim",                                         "ipk"};         private object[][] data = {         {"", new integer(0),new double(0)}         };          public boolean iscelleditable(int row, int col) {             if (col < 2) {                 return false;             } else {                 return true;             }         }         public void setvalueat(object value, int row, int col) {             if (debug) {                 system.out.println("setting value @ " + row + "," + col                                    + " " + value                                    + " (an instance of "                                    + value.getclass() + ")");             }              data[row][col] = value;          }          private void printdebugdata() {             int numrows = getrowcount();             int numcols = getcolumncount();              (int i=0; < numrows; i++) {                 system.out.print("    row " + + ":");                 (int j=0; j < numcols; j++) {                     system.out.print("  " + data[i][j]);                 }             }         }     } 

  1. for jtable based on abstracttablemodel required override

  2. i'd use defaulttablemodel (see post, how easy be), recomend newbee

  3. everything described in jtable tutorial, rest (correctly) in concrete apis


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -