2011-05-18 42 views
1

我想创建一个列并在此表的最后一列中安装一个按钮。带按钮的表

public JPanel pinakas(String[] pinaka) { 
     int sr = 0; 
     //int ari8mos =0; 

     String[] COLUMN_NAMES = {"Κωδικός", "Ποσότητα", "Τιμή", "Περιγραφή", "Μέγεθος", "Ράτσα"}; 
//pio panw mporoume na pros8esoume ws prwto column to "#", wste na deixnei ton ari8mo ths ka8e kataxwrhshs 
     DefaultTableModel modelM = new DefaultTableModel(COLUMN_NAMES, 0); 
     JTable tableM = new JTable(modelM); 
     JPanel mainPanel = new JPanel(new BorderLayout()); 
     mainPanel.add(new JScrollPane(tableM), BorderLayout.CENTER); 

     Display disp = new Display(); 
     while (pinaka[sr] != null) // !!!!tha ektupwsei kai mia parapanw "/n" logo ths kataxwrhshs prwtou h teleytaiou mahmatos 
     { 
      String[] temp5 = disp.lineDelimiter(pinaka[sr],6, "#"); 
      Object[] doge = { temp5[0], temp5[1], temp5[2], temp5[3], temp5[4], temp5[5]};//edw mporoume sthn arxh na valoume to ari8mos gia na fainetai o ari8mos twn kataxwrhsewn 
      modelM.addRow(doge); 
      sr++; 
      //ari8mos++; 
     } 

     return mainPanel; 
    } 
+2

[Swing JTable教程](http://download.oracle.com/javase/tutorial/uiswing/components/table.html)解释了如何使用表格单元编辑器来充当JButton。如果你还没有研究它,我建议你去那里作为第一个开始。 – 2011-05-18 17:39:34

回答