Results 1 to 6 of 6

Thread: How to use DefaultCellEditor class?

  1. #1
    Join Date
    Dec 2009
    Posts
    32

    How to use DefaultCellEditor class?

    Hi friend,

    I have one query to discuss with you and which is related to the DefaultCellEditor class. In one of my project I will need to use DefaultCellEditor class of java. But I don't anything about this java class. I searched lost of various websites for 'DefaultCellEditor class, but didn't get enough details. If you posses knowledge about DefaultCellEditor class, then please let aware about the same. I would greatly appreciate your any help over DefaultCellEditor class .

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to use DefaultCellEditor class?

    Hi,

    A DefaultCellEditor class is used as a default editor for table and tree cells. A 'javax.swing.AbstractCellEditor' is nothing but the parent package for the DefaultCellEditor class of java. This java class implements four interfaces namely as TableCellEditor, TreeCellEditor, CellEditor, Serializable. A DefaultCellEditor class of java language is entends the class known as 'classAbstractCellEditor'

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to use DefaultCellEditor class?

    Following are some essential methods of the DefaultCellEditor class:
    • shouldSelectCell(EventObject anEvnt)
    • setClickCountToStart(int cnt)
    • isCellEditable(EventObject anEvnt)
    • getTreeCellEditorComponent(JTree tree, Object val, boolean bl, boolean expanded, boolean leaf, int rw)
    • getTableCellEditorComponent(JTable table, Object val, boolean bl, int row1, int clm)

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use DefaultCellEditor class?

    Hi friend,

    If you want to know about the use of DefaultCellEditor class, then please refer following java code:
    Code:
    import javax.swing.DefaultCellEditor;
    import javax.swing.tree01.TreeCellEditor;
    
    public class DefaultCellEditorMain {
    
      public static void main(final String argvs[]) {
        JFrame frame002 = new JFrame("Editable Tree");
        frame002.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Object array[] = {Boolean.TRUE, Boolean.FALSE, "Hello"};
        JTree tree01 = new JTree(array);
        tree01.setEditable(true);
        tree01.setRootVisible(true);
        JCheckBox checkBox1 = new JCheckBox();
        TreeCellEditor editor1 = new DefaultCellEditor(checkBox1);
        tree01.setCellEditor(editor1);
    
        JScrollPane scrollPane1 = new JScrollPane(tree01);
        frame002.add(scrollPane1, BorderLayout.CENTER);
        frame002.setSize(200, 150);
        frame002.setVisible(true);
      }
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: How to use DefaultCellEditor class?

    Below I have given some constructors of DefaultCellEditor class along with their parameters:
    1. DefaultCellEditor(JComboBox cmbBox1)
    2. DefaultCellEditor(JTextField txtField1)
    3. DefaultCellEditor(JCheckBox chkBox1)
    4. getClickCountToStart()

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to use DefaultCellEditor class?

    Hi,

    Following code of java will demonstrate you the use of DefaultCellEditor(JComboBox com) method of DefaultCellEditor class:
    Code:
    import javax.swing.DefaultCellEditor;
    import javax.swing.JComboBox;
    import javax.swing.tree.TreeCellEditor;
    
    public class DefaultED {
    
      public static void main(final String args[]) {
        JFrame HBP = new JFrame("Editable Tree");
        HBP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JTree tree = new JTree();
        tree.setEditable(true);
    
        DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
        String elements[] = { "A", "B", "C", "D" };
        JComboBox comboBoxF = new JComboBox(elements);
        comboBoxF.setEditable(true);
        TreeCellEditor comboEditorF = new DefaultCellEditor(comboBoxF);
        TreeCellEditor editorF = new DefaultTreeCellEditor(tree, renderer, comboEditorF);
        tree.setCellEditor(editorF);
        JScrollPane scrollPane1 = new JScrollPane(tree);
        HBP.add(scrollPane1, BorderLayout.CENTER);
        HBP.setSize(300, 100);
        HBP.setVisible(true);
      }
    }

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  3. Difference among concrete class and abstract class
    By Roxy_jacob in forum Software Development
    Replies: 4
    Last Post: 07-12-2009, 01:22 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,418,649.16762 seconds with 17 queries