Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JavaSwing中使用CellEditor_Java_Swing_Tablecelleditor - Fatal编程技术网

如何在JavaSwing中使用CellEditor

如何在JavaSwing中使用CellEditor,java,swing,tablecelleditor,Java,Swing,Tablecelleditor,我将创建JPanel的JList,JPanel蠕动aJtextfield和JLabel,我正在创建此JPanel的列表 public class CasofTablecase extends javax.swing.JPanel { /** * Creates new form CasofTablecase */ public CasofTablecase() { initComponents(); } /** *

我将创建
JPanel
JList
JPanel
蠕动a
Jtextfield
JLabel
,我正在创建此JPanel的列表

public class CasofTablecase extends javax.swing.JPanel {

    /**
     * Creates new form CasofTablecase
     */
    public CasofTablecase() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to                       


    // Variables declaration - do not modify                     
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration                   
}
我正在为我的类添加一个
DefaultListCellRenderer
(类的
Jlist
):

公共类dlcr扩展了DefaultListCellRenderer{
@凌驾
公共组件getListCellRenderComponent(JList列表、对象值、int索引、布尔isSelected、布尔cellHasFocus){
返回(新的CasofTablecase());
}
}

我的问题是,如果我点击一个
Jtextfield
来写一些东西,但是没有发生什么事情,那么如何使用
CellEditor

JList不支持编辑。您应该使用JTable。有关更多信息和工作示例,请参阅Swing教程中的部分。类似的问题,如果您真的想知道为什么建议使用
JTable
,请查看
   public class dlcr extends DefaultListCellRenderer{

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            return (new CasofTablecase());
        }



    }