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

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

最佳答案

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

关于java - 带按钮表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6048735/

10-09 05:07