Changing the event that starts JTree cell editor

I've implemented a JTree that uses a custom cell renderer and editor. Everything is going well except for a look and feel issue. When I double click on a JTree entry or single click on a node that has already been selected, the cell editor starts immediately. This is way to generous, and I'm finding I'm often editing cells when I just want to navigate the tree.
I'd much prefer to have the edit event be something harder to do like a right click or a triple left click. Is there a way to change the event that starts the JTree cell editor?

DefaultCellEditor provides a method boolean isCellEditable(EventObject anEvent), by default it always returns true. Override that method in your cell editor to only return true if the event is a right click, or whatever you want.

Similar Messages

  • JTree: Cell Editor takes few click to start editing

    I have a JTree and have set the user defined renender and cell editor.
    However, user has to click continuously for some time to start the editing operation. How can I start the edit operation immediately after one click only.
    TIA
    Sachin

    ((DefaultCellEditor)myTable.getCellEditor()).setClickCountToStart(1);
    Remember that a click is a mouse press and release without moving the mouse.

  • Trying to change the color of a single cell

    hi, I am trying to change the color of a single cell when mouse moves over it, but couldn't do it. i even tried my own renderer, but it doesn't work. can anybody help ?

    Here is what I am trying to do. I am displaying some data in a java JTable retrieved from a table in database. What is needed is when user moves his mouse over any cell in the third column, the cursor should change to hand cursor and possibly the background color should also change, to indicate the user that this cell is clickable. I have to show some other report when user clicks any cell in column three. The code follows as
    import java.awt.*;
    import java.sql.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.sql.rowset.*;
    import javax.swing.table.*;
    public class MouseMotionInTable extends JFrame
    public static void main(String[] args)
      MouseMotionInTable f = new MouseMotionInTable();
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension dim = tk.getScreenSize();
      int w = dim.width;
      int h = dim.height;
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setBounds((w-600)/2, (h-300)/2, 600, 300);
      f.setVisible(true);
    MouseMotionInTable()
      Connection con = null;
      CachedRowSet crs = null;
      try
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       con = DriverManager.getConnection("jdbc:odbc:FMS", "", "");
       Statement st = con.createStatement();
       String query = "SELECT ItemName, Alias, ItemReOrderQuty, ItemMeasure FROM ItemInfo";
       ResultSet rs = st.executeQuery(query);
       crs = new com.sun.rowset.CachedRowSetImpl();
       crs.populate(rs);
       st.close();
      catch (SQLException e)
       e.printStackTrace();
      catch (ClassNotFoundException e)
       e.printStackTrace();
      finally
       if(con != null)
        try
         con.close();
        catch (SQLException e)
         e.printStackTrace();
      DBTableModel model = new DBTableModel(crs);
      table = new JTable(model);
      JPanel center = new JPanel();
      center.setLayout(new BorderLayout());
      center.add(new JScrollPane(table), BorderLayout.CENTER);
      add(center, BorderLayout.CENTER);
      table.addMouseMotionListener(new MouseMotionAdapter()
       public void mouseMoved(MouseEvent me)
        int col = table.columnAtPoint(new Point(me.getX(), me.getY()));
        int row = table.rowAtPoint(new Point(me.getX(), me.getY()));
        if(col == 2)
         Object val = table.getValueAt(row, col);
         boolean isSelect = table.isCellSelected(row, col);
         boolean focus = table.isCellSelected(row, col);
         TableCellRenderer cellRender = table.getCellRenderer(row, col);
         Component comp = cellRender.getTableCellRendererComponent(table, val, isSelect, focus, row, col);
         comp.setCursor(new Cursor(Cursor.HAND_CURSOR));
         comp.setBackground(Color.yellow);
    private JTable table;
    class DBTableModel extends AbstractTableModel
    ResultSet rs;
    ResultSetMetaData rsMeta;
    DBTableModel(ResultSet rs)
      try
       this.rs = rs;
       rsMeta = rs.getMetaData();
      catch(SQLException e)
       e.printStackTrace();
    public int getColumnCount()
      try
       return rsMeta.getColumnCount();  
      catch(SQLException e)
       e.printStackTrace();
      return -1;
    public String getColumnName(int c)
      try
       return rsMeta.getColumnName(c+1);
      catch(SQLException e)
       e.printStackTrace();
      return "";
    public int getRowCount()
      try
       rs.last();
       return rs.getRow();
      catch(SQLException e)
       e.printStackTrace();
      return -1;
    public Object getValueAt(int r, int c)
      try
       rs.absolute(r+1);
       return rs.getObject(c+1);
      catch(SQLException e)
       e.printStackTrace();
      return "";
    public boolean isCellEditable(int r, int c)
      return false;
    public Class getColumnClass(int c)
      return getValueAt(0,c).getClass();
    }

  • Changing the Event View Field Display Order on a Calendar

    We'd like to change the display of a calendar event to show the Title on top and the time below. This is how it currently looks below. Is there a way to change it?
    Orange County District Attorney

    Hi,
    According to your post, my understanding is that you wanted to change the Event View Field display order on a Calendar.
    You need to insert the code below into a Content Editor Web Part.
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    function changeCalendarOrder() {
    $(".ms-acal-sdiv").each(function () {
    var arr = $(this).find('div').toArray();
    var temp;
    temp = arr[0];
    arr[0] = arr[2];
    arr[2] = temp;
    $(this).html(arr);
    //alert($(this).html());
    _spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');
    // hook into the existing SharePoint calendar load function
    function calendarEventLinkIntercept() {
    var OldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4b;
    SP.UI.ApplicationPages.CalendarNotify.$4b = function () {
    OldCalendarNotify4a();
    changeCalendarOrder();
    </script>
    The result is as below:
    Thanks,
    Linda Li                
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How do I change the way that my company name appears when googled?

    How do I change the way that my company name appears when it is googled?  Currently it only shows up as part of my company name followed by the website listed below and then the start of a description.  I would like to make it so my entire company name show up as the title when searched.  I used iWeb to create the site.  Please Help!  Thanks:)

    Put the whole company name in the title tag...
    http://www.iwebformusicians.com/Search-Engine-Optimization/Tags.html

  • How to change the background color of a cell in datagrid using flex3

    i want to change the background color of a cell.....how can i achieve this.....and also i want to know how a spacing cane be done between cells in a datagrid...plzzz help me???

    The only way I can see to do this is to use an item renderer for your cells.  This is really scruffy and would need tyding up, and maybe with a little more time could do better or someone else may have an idea but none the less this works.
    Define a custom component as below;
    This has logic to see what the value of the data is proveided by the dataprovider for the row, and if it matches the conditions in this case is equal to 5 sets the background color.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="88" height="26" dataChange="doColor()" borderColor="#000000" borderStyle="solid"
        backgroundAlpha="1">
        <mx:Script>
            <![CDATA[
                private function doColor():void {
                    if (data.value == 5) {
                        setStyle('backgroundColor', 0xcccccc);
                    } else {
                        setStyle('backgroundColor', 0xffffff);
            ]]>
        </mx:Script>
    </mx:Canvas>
    Now just apply the item renderer in the datagrid and that will do it.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  xmlns:ns1="*">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var ac:ArrayCollection = new ArrayCollection([
                    {value : 1},
                    {value : 2},
                    {value : 3},
                    {value : 4},
                    {value : 5},
                    {value : 6},
                    {value : 7},
                    {value : 8},
                    {value : 9},
                    {value : 10}
          ]]>
        </mx:Script>
        <mx:DataGrid x="40" y="36" width="408" height="193" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="value" itemRenderer="MyComp"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    I hope this helps
    Andrew

  • How do I change the background of a single cell or a row in a table?

    How do I change the background of a single cell or a row in a
    table? I doesn't seem to be letting me do that.

    Are you using the latest DW? If so, then it isn't letting you
    because
    bgcolor is deprecated and shouldn't be used.
    The correct way is to use css to define the background of a
    cell
    CSS:
    .blackcell {background-color: black;}
    HTML:
    <td class="blackcell">whatever in the cell</td>
    Nadia
    Adobe® Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    ~ Template Customization ~
    http://www.csstemplates.com.au
    Spry Widget Examples
    http://www.dreamweaverresources.com/spry-widgets/
    "dm25" <[email protected]> wrote in message
    news:f4jr5h$luu$[email protected]..
    > for some reason that doesn't always work. When I click
    inside a cell, it
    > doesn't give me an option to change the background
    color.

  • Error trying to change the value property of a cell with decimals

    This is a script question.
    I’m using a system defaulting to Spanish, so the decimal delimiter is the comma.
    During a script I need to change the property value of a cell multiplying it by -1. As an example, I want to change 1,25 into -1,25.
    This is how try to do it:
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set selection range to first cell
    set mi_cell to (value of first cell of selection range) * -1
    set value of first cell of selection range to mi_cell
    end tell
    The expected result is wrong provided that the original value of the cell has decimal value. Otherwise is correct.
    See examples of what happen after running this piece of the script:
    1,25 becomes -125,00 instead of -1,25
    6,00 becomes -6,00 (in this case is correct)
    Does anybody know how to solve this problem?
    Thanks in advance.
    Ratz

    This was described here in several scripts.
    Before setting the value of a cell to a number or a date, the value must be coerced to a string.
    It's the only way available to take care of localization features.
    Your script must be
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set selection range to first cell
    set mi_cell to (value of first cell of selection range) * -1
    set value of first cell of selection range to mi_cell as text
    end tell
    or better
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set mi_cell to (value of first cell) * -1
    set value of first cell to mi_cell as text
    end tell
    CAUTION : don't code
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set mi_cell to -(value of first cell)
    set value of first cell to mi_cell as text
    end tell
    which is supposed to do the same but would return the opposite of *_the integer value_* of the cell.
    Yvan KOENIG (VALLAURIS, France) dimanche 13 février 2011 16:06:39

  • I changed my gmail e-mail password. How do I change the password that Thunderbird uses to log in to gmail.

    I changed the password used to access my gmail account. Thunderbird is still using the old password to access the account. How do I change the password that Thunderbird is using. The last time this happened I ended up creating a new Thunderbird account for gmail. Creating the new Thunderbird account at least let me enter the new password. I really don't want to have three Thunderbird accounts for the same gmail account.
    Please do not respond with suggestions about using Password Manager. I do not use it and do not intend to start. I looked and none of my Thunderbird passwords are displayed there. All I want to do is change the password in Thunderbird. If Thunderbird does not have a feature allowing you to change it's passwords, one should be added.

    This is the only way.
    http://kb.mozillazine.org/Setting_and_changing_email_passwords

  • Change the Event username and password

    I am trying to change the event subscription username and password for the Cisco IPS module for the ASA's. I have them tied into the IME, but went through the setup I must have goofed and checked the box that said use same username and password for event subscription as configuration values.

    While I see this marked as answered, the answer is vague.   It lacks real information about the account that was reset.  I do notice that if this event is filtered that the SID is incremented by one for each event.
    Example:
    S-1-5-21-282.....-....-....-5169
    S-1-5-21-282.....-....-....-5170
    S-1-5-21-282.....-....-....-5171
    and so on and so forth.  As it is incremental, there may be an account, local to the machine, for a service that is turned off and the computer may attempt to reset the account when the service cannot be connected.  Possibly a disabled service,
    a bad entry in the registry....  just my thoughts.  If we observe the SID, it is a different account that is reset with each iteration of that event.
    R, J

  • [svn:fx-trunk] 8271: Change the event type of List-based component's change , changing and caretChange events to a new event class: spark.events. IndexChangeEvent.

    Revision: 8271
    Author:   [email protected]
    Date:     2009-06-25 16:25:28 -0700 (Thu, 25 Jun 2009)
    Log Message:
    Change the event type of List-based component's change, changing and caretChange events to a new event class: spark.events.IndexChangeEvent.
    QA: Yes
    Doc: Yes
    Checkintests: Pass
    Mustella: List/DDL/ButtonBar tests pass
    Reviewers: Hans & Jason
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/events/IndexChangedEvent.as
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/ButtonBarE xample.mxml
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/DropDownLi stExample.mxml
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/ListExampl e.mxml
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ButtonBar.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
    Added Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/events/IndexChangeEvent.as

    Are those components in a SWC?  I would expect them to also have a namespace
    that looks more like http://.....
    Otherwise, make sure the path to the components are correct.

  • How do I change the table to start from right to left

    How do I change the table to start from right to left

    iWork apps have bugs that make them unsuitable for RTL scripts in various ways.  You might be better off using a different app if your work has a lot of RTL text.

  • When I want to delete a meeting I have the message "the attendee may not change the event". How can it be done?

    When I want to delete a meeting I have the message "the attendee may not change the event". How can it be done?
    Quand je veux effacer un RV le message "the attendee may not change the event". Comment faire?

    You indicate you have just started using Thunderbird, so what email program displays them "as usual"

  • How do I change the programs that open upon startup?

    I am trying to figure out how to change the programs that open when I start my computer.

    To add or remove them, go to: Apple / System Preferences / Accounts / Login Items
    To add then without going to Login Items, right (control) click on the Dock Icon, choose Option and click Open at Login.

  • How to properly change the server that is running service application?

    Hello
    In our SharePoint 2013 farm we use the User Profile service applications very heavily.
    I want to change the server that is hosting the service. The User Profile service application which is currently running on: (Server-1), But, I want it to be running on: (Server-2) instead.
    Is this (https://technet.microsoft.com/en-us/library/ee704549.aspx?f=255&MSPPError=-2147217396) the
    right/proper way to do it? What about the order?
    I mean: Should I go to: Manage services on server > Server-2 > Start: User Profile. 
    After that: Manage services on server > Server-1 > Snbsp;
    Or, The other way around:
    I mean: Should I go to: Manage services on server > Server-1 > Snbsp;
    After that: Manage services on server > Server-2 > Start: User Profile. 
    Or, Is it a totally different way? Does the same way apply on other service applications too e.g. Managed Metadata too ? 
    I am asking about this because I really want to be super cautious while doing this change to avoid crashing the service or corrupting it.
    Thank you !

    The order doesn't really matter if you're quickly doing this, but you could start it on the new and stop it on the old.
    User Profile Service should generally run on the 'WFE(s)' since it is an end-user facing service.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Maybe you are looking for