When do I need to use a cell editor in a JTree?

I'm currently trying to add checkboxes to nodes in a JTree. I use a panel containing the check box and a label for rendering. I did this because I want only the checkbox to respond to a mouse click and not the text associated with it. I've read several articles online (including the tutorial) and seen sample code as well. Do I need a cell editor or just have a cell renderer with a mouse listener? I've seen it done both ways.

Let me rephrase the question.
If I want to display a checkbox and a label as a node in a Jtree, which way should this be done (with or without a cell editor)? What are the advantages/disadvantages to each approach and what is recommended by Sun?
I ended up not using a cell editor, but I've read posts on various sites where it was stated that if the user has interaction with the node then an editor should be used (with no other explanation as to why). I guess my main concern is that there might be a down side from not using a cell editor that I'm not aware of.

Similar Messages

  • When do I need to use "void" ?

    When do I need to use "void" ?
    Thanks!!!

    When do I need to use "void" ?whenever you like to use it? although normally when e.g a method does not return a value
    public void sayHello() {
       System.out.println("Hello");
    }

  • ODI Agent - when do i need to use?

    can anybody explain me the perpose of ODI Agent? and when do i need to use Agent?
    Edited by: knidhi on Oct 5, 2009 3:31 PM
    Edited by: knidhi on Oct 5, 2009 4:07 PM

    If I could finesse your answer slightly, hopefully to help (or confuse):
    There are multiple agent types:
    - the Local (No agent): this opens additional threads in the current GUI process. The agent will just run as additional threads in your current process, using the same settings as your GUI environment.
    - a standalone agent: if you start an agent from the commandline using the agent.sh/bat. This will start a "listener agent". It starts up and passively listens for execution requests. When a request is passed to the agent, it includes all the necessary information to connect to the repository etc. All this information is there in the invocation package. (for more information on what is passed look at the documentation for the invocation API or at the ODIInvoke webservice)
    - a scheduler agent: when you start a scheduler agent from the commandline with the agentscheduler.bat/sh file, it will read from the odiparams.sh/bat file the connectivity paramaters for the repository, where it will "look itself up" based on the agent name passed, to find out what scenarios it should be scheduling. This agent may also take requests, just like the standalone agent described above.
    - a task may also be invoved at the opertaing system command level using startscen.bat/sh. This will start a standlone agent for the duration of this execution only, which not listen for other requests, it reads its parameters from the command line (for which sceenario, version and context) and from the odiparams file for the repository connectivity parameters as to where to find the requested scenario and where the execution will be logged.

  • I need to use the PDF editor so I can sign or edit documents already on pdf format. Please advise?

    I need to use the PDF editor so I can sign or edit documents already on pdf format. Please advise?

    As per my understanding , To disable the field RV45A-KWMENG based on the condition for Transaction VA01/VA02.
    The conditions which i need to check is Order Type and item category.
    I understand that this is the code which i need to insert for disabling the field but i have a question here, where is the condition here and how the system understand for this field RV45A-KWMENG it has to disable. I think we need give the condition as if RV45A-KWMENG....... Another one if iam not wrong we need check that it has to be done in VA01 and VA02 then only this condition should be executed.
    IF VBAK-AUART EQ 'XXX' OR VBAP-PSTYV EQ TANN .
    IF SCREEN-NAME = 'XXX'.
    SCREEN-ACTIVE = 0
    ENDIF.
    ENDIF.
    Please suggest me the better way how can i do it in the coding.
    Awaiting for ur prompt reply.

  • How to use Jtable cell Editor

    HI,
    Here trying to populate the ImageIcon using JLabel in Jtable cell. For that I used DefaultCellRenderer. For implement the mouseListener to label I used the DefaultCellEditor. I am facing one problem here. After editing the label I selected the second row of the table, the first row image is not displaying. Can any one help on this issue?
    public class LabelCellEditor extends DefaultCellEditor {
    public LabelCellEditor(final JCheckBox checkBox) {
    super(checkBox);
    public Component getTableCellEditorComponent(final JTable table, final Object value,
    final boolean isSelected, final int row, final int column) {
    Color background = null;
    background = ColorManager.SELECTED_ROW_BGCOLOR;
    labelVal = (JLabel) value;
    labelVal.setOpaque(true);
    labelVal.setFont(FontManager.TABLE_DATA_FONT);
    labelVal.setBackground(background);
    labelPanel = new JPanel();
    labelPanel.setOpaque(true);
    labelPanel.setBackground(background);
    labelPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    labelPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    labelPanel.add(labelVal);
    return this.labelPanel;
    public Object getCellEditorValue() {
    return this.labelPanel;
    public class LabelCellRenderer extends DefaultTableCellRenderer {
    public LabelCellRenderer(final int alignment) {
    //setHorizontalAlignment(alignment);
    this.align = alignment;
    public Component getTableCellRendererComponent(final JTable table, final Object value,
    final boolean isSelected, final boolean hasFocus, final int row, final int column) {
    if (value != null) {
    if (value instanceof JLabel) {
    labelVal = (JLabel) value;
    labelVal.setOpaque(true);
    labelVal.setFont(FontManager.TABLE_DATA_FONT);
    labelVal.setBackground(background);
    labelVal.setHorizontalAlignment(this.align);
    labelVal.setBorder(new EmptyBorder(0, LRPADD, 0, LRPADD));
    JPanel panel = new JPanel();
    panel.setOpaque(true);
    panel.setBackground(background);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel.setBorder(new EmptyBorder(5, 0, 0, 0));
    panel.add(labelVal);
    return panel;
    return this;
    }

    With more than 30 postings you should know by now how to use the "Code" tags when posting code so the code reatains its original formatting and is therefore more readable.
    There is no need to create a custom editor, here is a simple example.

  • How to use Radiobutton Cell Editor in Table using Master Column

    Hi Guys,
    I have a Table that uses a Master Column.  I need to have a field that uses a Radio Button type cell editor.  A user should only be ably to select ONE row via the Radio Button at a time.
    I have done all this but I only seem to be able to select multiple radio buttons instead of only one.  It is like the radio buttons do not get "regognised" as a group.  Could you please advise as I probably set the "keyToSelect" and "selectedKey" properties incorrectly.
    tks
    Christiaan

    I think the following should work:
    Context:
    Rows (node,c=0:n)
    --- rowIndex (integer)
    selectedRowIndex (integer)
    Bind the "selectedKey" property of the radio button (cell editor) to attribute "selectedRowIndex" (outside table data source node) and bind "keyToSelect" to attribute "Rows.rowIndex". Make sure that the "rowIndex" attribute will contain the index of the node element in node "Rows".
    Armin

  • How to use the cell editor in FICO reports for YTD

    HI experts,
    I am working with BI7.0, in the below report, i have displayed result based on user input.but how to calculate the YTD values. User will give the input like 072007, results will be display one year from 072007 to 062006 (one yearback) and one more column is YTD
    Report structure is :
         user input(single value): 072007
              AUG06....JAN07....JULY07....YTD
    KEYFIGURE-1        453      -
    777     -
       232       -
      777 (Only Jan07 value of Keyfigure-1)   
    KEYFIGURE-2        879      -
    233        -
    123       -
      ???? (only sum from Jan07 to July07)
    KEYFIGURE-3        212            -
    879      -
    989                -
    KEYFIGURE-4        234            -
    656      -
    788                   -
    KEYFIGURE-5        345            -
    878      -
    878                 -
    KEYFIGURE-6        767            -
    767       -
    323                 -
    KEYFIGURE-7        879            -
    878     -
    999                -
    999 (Only last value of keyfigure-7 (July07)
    in the above report, total 7 keyfigures so 7rows of YTD column
    1) in the first YTD column, how will display only one value (keyfigure-1) of Jan07?
    2) in the last YTD Column, how will display only one value (keyfigure-7) of July07?
    3) from 2 to 6 columns of YTD, how will display the sum from Jan07 to July07?
    Note: months will be changed based on user input(single Value)
    how can use cell editor for above the senior.
    if any option is availabel please let me know
    Thanks
    kishore

    I think the following should work:
    Context:
    Rows (node,c=0:n)
    --- rowIndex (integer)
    selectedRowIndex (integer)
    Bind the "selectedKey" property of the radio button (cell editor) to attribute "selectedRowIndex" (outside table data source node) and bind "keyToSelect" to attribute "Rows.rowIndex". Make sure that the "rowIndex" attribute will contain the index of the node element in node "Rows".
    Armin

  • Creating a Cell Editor for a JTree

    Hi...
    I would like to be able to edit the nodes of a JTree dynamically, but I'm not sure how to do it. I have unsuccessfully tried to implement a celleditor by extended the DefaultTreeCellEditor. The editing works fine, but once the cell has been edited, I get a ClassCastException.
    I know that I need to get the edited value and then make appropriate changes to the DefaultMutableTreeNode object stored, but I am not sure where to do all this. I would really appreciate some tips on where to get the edited value entered, and how I can access the object being edited. Thanks.
    ..VJ..

    So, you have a big table whose cells each contain a little table. I assume you already have the little tables working correctly with cell editors and so on, and you want to write a cell editor for the big table. Correct?
    My problem with this is that I can't imagine how this would actually work in practice. Suppose I click on a cell in the big table; then the cell renderer displays the appropriate little table. At this point should I see one of the cells in that little table selected, and should I be able to use the Tab key to move around the little table? And if so, then I can't use the Tab key to move around the big table. Next, suppose I press F2 indicating that I want to edit the little table. What should change? Should I now be able to tab around the little table, whereas I couldn't before? And if so, how do I indicate that I have stopped editing the little table? Pressing Enter indicates to the little table's cell editor that its editing is finished, but how should I tell the big table's cell editor that its editing is finished?
    Perhaps if you can answer this, you may have a better idea of how to solve your problem. Sorry I only have questions and not answers.

  • When do I need to use UITableView.insertSections: (and deleteSections:)?

    In a plain UITableView, is it necessary for me to explicitly call insertSections to create the number of sections in my table or is it sufficient to just return the number of sections via my numberOfSectionsInTableView data source method? I've been under the assumption that as long as I return the correct number of sections in numberOfSectionsInTableView, UITableView will take care of creating the proper number of sections in the table. It certainly seems to do that when you initially create your table.
    But my table data can change over time. Rows and sections can come and go. What I've been doing is simply calling reloadData on my table view whenever the underlying data changes and then letting my numberOfSectionsInTableView and numberOfRowsInSection data source methods report to the table the new number of elements. This appears to work some of the time. But sometimes, after a section has disappeared out of the data source, the table view leaves the header view (that gray bar with a section title) visible and floating above the table - even though I've called reloadData and my numberOfSectionsInTableView method returns the new number of sections. At this point, you can't get rid of the section header view.
    What I've discovered is that I must explicitly tell the table that sections have been deleted by calling deleteSections:withRowAnimation:. The converse holds true. If my data source has added new sections, then I must explicitly call insertSections:withRowAnimation:.
    What I don't understand: why do I have to use insertSections to add new sections as opposed to initially, when I created the table, I did not have to use that call. I simply let my numberOfSectionsInTableView inform the table view how many sections there were?
    This is an issue for me because of the way that my data changes. I do not know what sections in my data were deleted. I only know that something changed in the data and I need to repopulate the table.

    have you tried calling "reloadData" on the tableView?

  • Screen Saver when calling and need to use the Keypad, the screen saver doesn't detect the phone has left the ear and blanks out the screen.  Even ending a call is difficult as the screen blanks out within seconds

    I have to use the Keypad a lot when making calls.  Make the call, the Robot then asks to enter a number for a service, pull the phone down from the ear, the screen may light up for a second, but then the screen saver cuts in, blanking the screen out.  Sometimes you hit the Home Key to awaken the sccreen, enter your number and then back to the ear to hear the next set of instructions.  Back and forth just trying to enter the options is a pain.  Sometimes even trying to end the call, the screen blanks out and you fight to try and end a call.
    If I use the Speaker function the keypad works; the speakler phone is not alway appropriate. 
    It appears that the phone gyro, doesn't detect the phone has moved from the ear to the viewing angle.  This wasn't an issue until recently and I can't remeber if it's the iPhone 5 or one of the updates.  It definitly wasn't there earlier on, as I threw away an Windows 6.5 phone for the same problem. 
    I'm not sure if it's a hardware or software (design) issue.

    It is not the gyro. This has everything to do with the iPhone's prioximity sensor.
    Are you using a case that may be blocking or partially blocking the proximity sensor? If you are using the case, remove the case prior to the next call to see if the same occurs without the case.

  • IE hangs when applet closed - need to use taskman

    I am fairly new to java and have been working on an application that interfaces a commercially available webserver with a 8 bit microcontroller. The micro communicates with the webserver via RS-232 but the applet gets the info through ethernet.
    My problem is that when the applet is waiting for data using the following code, if the browser is closed(IE) IE hangs and requires using the taskman to terminate the program. If the browser is closed in any other condition it shuts down normally. What can I do to get this process to terminate correctly?
    Thanks in advance.
    while ( (gtp != null) && (count <= 42) ) {     
          if (gtp.available() > 0){
         in = gtp.receive();
         // store received board disc status bytes
              for (i = 0; i < in.length; i++) {
                   if (board[count] != in[i]-48)
                        iMove_loc = count;     
                   board[count] = in[i]-48;
                   count = count +1;          
    }

    That's a very tight loop, hogging the CPU all the while. Time for a redesign, to be sure, to get it to be 'notified' when data is available rather than polling like that. Or at least throttle down the polling quite a bit by introducing sleeps.
    Also, I hope that loop is in a separate thread from the applet's main thread.
    When you shut down IE, the applet's stop/destroy methods will be called - at which point you should 'notify' the code being executed in that loop that it's time to get out.

  • Firefox freezes or does not go away when closed I need to use window task manager

    In Windows 7 Firefox often freezes or will not go away even if I close it.
    So far the only way to resolve this issues if it last is to close it with Windows Task Manager.
    Which obviously means that if I was frozen I loose any other tab that is open

    See http://kb.mozillazine.org/Firefox_hangs and [[Firefox hangs]] (Hang at exit)

  • Custom JTable cell editors and persistence

    I have a JTable with an underlying data model (an extension of AbstractTableModel) that uses custom cell editors in the last column. The cell editor in that column, for a given row, depends on the value selected in another column of the same row. The cell editors include text, date, list, and tree editors (the last one in a separate dialogue). The number of rows is changeable.
    I have need to persist the data for a populated table from time to time, for restoration later on. I've achieved that, such that the data model is recreated, the table appears correct, and the appropriate cell editors activated (by creating new instances of the editors' classes).
    However, my problem is that the (custom) cell editors do not reflect the data in the model when editing mode is begun the first time after restoration. Eg. the text editor is always empty, the list editor shows the first item, and no node is selected in the tree editor.
    If I've restored the model correctly, should the editors properly reflect the underlying data when they are set to editing mode?
    I suspected not, and thus tried to explicitly 'set' the correct values immediately after each editor is recreated ... but to no avail.
    Does anyone have any thoughts, or experience with something similar? I'm happy to supply code.

    You can use html tags within Swing, so I think you can do the following:
    * MyRenderer.java
    * Created on 26 April 2007, 10:27
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package newpackage;
    import java.awt.Component;
    import javax.swing.JLabel;
    import javax.swing.JTable;
    import javax.swing.SwingConstants;
    import javax.swing.table.TableCellRenderer;
    * @author CS781RJ
    public class MyRenderer extends JLabel implements TableCellRenderer
        public MyRenderer()
            setHorizontalTextPosition(SwingConstants.RIGHT);
            setIconTextGap(3);
            setOpaque(true);
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean cellHasFocus, int row, int column)
            if (isSelected)
                setBackground(table.getSelectionBackground());
                setForeground(table.getSelectionForeground());
            else
                setBackground(table.getBackground());
                setForeground(table.getForeground());
            if (value instanceof String)
                if ((value != null) && (value.toString().length() > 0))
                    System.out.println("Value: " + value.toString());
                    setFont(new java.awt.Font("Tahoma", 0, 11));
                    setText("<html>" + value.toString().replaceAll("\n", "<br>") + "</html>");
            return this;
    }In the class that has the JTable, use the code AFTER declaring the values, columns, etc:
    jTable1.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());
    jTable1.setValueAt("Riz\nJavaid", 0, 0);One thing I haven't done is to resize the cell heights, make sure this is done.
    Hope this helps
    Riz

  • How can I use the Formula Editor?

    When I click on the "Insert" menu and try to insert a function, every option is grayed out. What additional software is needed to use the function editor in Pages?

    I'm nbot sure of what you try to achieve.
    The Insert Function menu item is designed to enter functions used in table's formulas.
    So it's active only if the cursor is in a table's cell.
    Maybe you are trying to draw an equation and this tyask requires the availability of the third product entitled MathType.
    Yvan KOENIG (VALLAURIS, France) mercredi 30 décembre 2009 22:18:09

  • Jcombobox as cell editor behaviour !

    1. on a normal combobox, when it got focus & i pressed up/down,
    the display will change depending on the selected item...
    but it's not when it used as jtable cell editor.
    is it possible to change that behaviour ?
    i want a normal combobox behaviour even when it used as cell editor
    2. i want to get combobox table cell editor by using double click,
    not single (the default)
    how can i do that ?
    sorry if this topic has been posted before, i found nothing on my search

    on a normal combobox, when it got focus & i pressed up/down,
    the display will change depending on the selected item...
    but it's not when it used as jtable cell editor.
    is it possible to change that behaviour ?
    i want a normal combobox behaviour even when it used as cell editora) You need to set celleditor property to false. ver overriding basisInit() method.
    this.putClientProperty("JComboBox.isTableCellEditor", Boolean.FALSE);b) You need to override custom keyboard action. Interhit from class and override the keyboard maps (Refer sample code below).
             * Adds keyboard actions to the JComboBox.  Actions on enter and esc are already
             * supplied.  Add more actions as you need them.
            protected void installKeyboardActions() {
                super.installKeyboardActions();
                ActionMap actionMap = SwingUtilities.getUIActionMap(comboBox);
                actionMap.put("togglePopup", new ToggleAction());
                actionMap.put("enterPressed", new EnterKeyAction());
                   actionMap.put("pageDownPassThrough", new CustomNavigationalAction(KeyEvent.VK_PAGE_DOWN));
                   actionMap.put("pageUpPassThrough", new CustomNavigationalAction(KeyEvent.VK_PAGE_UP));
                   actionMap.put("homePassThrough", new CustomNavigationalAction(KeyEvent.VK_HOME));
                   actionMap.put("endPassThrough", new CustomNavigationalAction(KeyEvent.VK_END));
            }With Regards,
    - Sushil

Maybe you are looking for

  • Can you use a iTunes card to purchase more storage for iCloud

    can you use a itunes card to purchase more storage for icloud

  • Frozen and can't connect to Itunes because of passcode??

    After trying to repower the Ipad it brought up the first screen of the cable to itunes. I connected the iPad to itunes to which it tells me it can't connect because of the passcode. Well since it is at the initial screen it won't let me enter the pas

  • Where to find hidden character...

    Where to find a update for this ? https://discussions.apple.com/thread/1899290?start=0&tstart=0 Right now i am looking for characters like "SOFT HYPHEN" Unicode: U+00AD, UTF-8: C2 AD is there any alternative hidden charracter on a Mac ? I now where t

  • Want to Remove  "drag photo here" in background and have nothing

    Hi there, I am using idvd 4 and the "Transparent Black Theme". I don't want to drag a photo onto the background, but just have it grey. I burned my dvd and it had the words "drag photo or movie here" in the background still. How do I take those words

  • Custom fields for FV50 table control

    Hello, The customer has a requirement to add 3 text fields to the table control in Transaction FV50. These fields are currently not available in the table control at all (I checked the Table settings Administrator). Further, no Screen/Transaction Var