带按钮的表

时间:2011-05-18 17:35:22

标签: java swing jtable

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

   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;
    }

1 个答案:

答案 0 :(得分:1)

Table Button Column显示了一种可能的解决方案。