How can I add the listener to the CellRenderer

My class named NoteColumnRenderer extends DefaultTableCellRenderer
and thhe getTableCellRendererComponent() returns JButton .
My question is how can I add MouseMotionListener to the JButton
or how can I add MouseMotionListener to the NoteColumnRenderer ?
The code below,and there is no effect
public class NoteColumnRenderer extends DefaultTableCellRenderer {
public NoteColumnRenderer(boolean multiSelection) {
super();
System.out.println("b="+this.getListeners(MouseMotionListener.class).length);
this.addMouseMotionListener(new MouseMotionListener(){
public void mouseDragged(MouseEvent e) {
System.out.println("mouse+++++++");
public void mouseMoved(MouseEvent e) {
System.out.println("mouse-------");
m_button.addMouseMotionListener(new MouseMotionListener(){
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouse=====");
public void mouseMoved(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouse=======");
System.out.println("a="+this.getListeners(MouseMotionListener.class).length);
m_multiSelection = multiSelection;
if (m_multiSelection) {
     m_check = new JCheckBox();
m_check.setMargin(new Insets(0, 0, 0, 0));
m_check.setHorizontalAlignment(JLabel.CENTER);
          } else
m_button.setMargin(new Insets(0, 0, 0, 0));
m_button.setSize(new Dimension(5, 5));
m_combobox = new JComboBox();
     } // IDColumnRenderer
     /** Mult-Selection flag */
     private boolean m_multiSelection;
     /** The Single-Selection renderer */
     private JButton m_button=new JButton();
     /* The Multi-Selection renderer */
     private JCheckBox m_check;
     private JComboBox m_combobox;
     protected void setValue(Object value) {
          if (m_multiSelection) {
               boolean sel = false;
               if (value == null)
     else if (value instanceof Boolean)
          sel = ((Boolean) value).booleanValue();
               else
          sel = value.toString().equals("Y");
               m_check.setSelected(sel);
          else
               if (value == null)
               else
     if(value.toString().length()>10)
m_button.setText(value.toString().substring(0,10)+"...");
                    else
                         m_button.setText(value.toString());
                    m_button.setBackground(Color.WHITE);
     public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
          setValue(value);
          if (m_multiSelection)
               return m_check;
          else
               return m_button;
}

Listener can be added to a cell editor, not cell renderer.
Set relevent cess(s) to setEditable == true when you use your custom cell editor.

Similar Messages

  • How can i add two values under the same property?

    Hi all,
    How can i add two values under the same property name in a
    prop list? For example:
    [question1: "item1","item2", question2: "item3","item4"]
    To be more precise, i am creating a property list and I want
    whenever a two values have the same property name to be added int
    he list under the same property. For example:
    gMyList.AddProp (#""&question&"" & x,
    member("input").text)
    question is a variable that is updated fromt he user's input.
    Now, whenever somethign like this happens:
    question = "question1"
    member("input").text = "five"
    question = "question1"
    member("input").text = "six"
    I want to output list to be:
    [question1: "five","six"] and so on
    Any ideas?

    Maybe you could make each property a list (so you have a
    property list full
    of lists), and add multiple values to the list held in a
    particular
    property?
    Cheers
    Richard Smith

  • How can I add a contact on the calendar for an event

    How can I add a contact on the calendar for an event

    It is between Repeat and Alert on my iPhone 5 with iOS 6.0.1
    I used the + on the top right to add the event and when you look vertically starting with the name, followed by location and then time the rest of the default things includ Invitees, among other items. 

  • How can i add a MouseMotionlistener  to the cells in the JTable?

    hi !
    how can i add a MouseMotionlistener to the cells in the JTable?

    yes i have.but that is different from adding MouseMotionlistener to the cells for me .
    i just want get the values where the mouse moves to .

  • How can I add a word to the dictionary?

    How can I add a word to the dictionary on my iPhone 6 plus?
    Thanks.

    There's not an option to add a word to the dictionary. However, after typing that word several times, it will start to recognize it and offer it as a suggested word.

  • How can I add an iView to the Detailed Navigation itself

    How can I add an iView to the Detailed Navigation itself and hides the other hyperlinks?

    To add an iview on the Detailed navigation side of a page:
    1.Double click the page which brings up the page editor.
    2.Click the Display dropdown box and choose Dynamic Navigation.
    3.Add an ivew to it.Save and add the page to a role to see the results.
    if this is not u wanted, post back here.
    Regards.

  • How can I add new songs to the top (not the bottom) of my playlist in iTunes?

    How can I add new songs to the top of my playlist in iTunes?
    I thought thats what it did before but now it automatically adds new songs to the bottom of the list.
    Not a huge issue but an annoyance.

    Go to your Music library
    Then, Click Playlist
    Then, Click the sort arrow until it points down.

  • HT3387 When I use pages the languages that I mainly use are English and Hebrew. The spellchecker works for English but not with Hebrew. How can I add another language to the spellcheck?

    When I use pages the languages that I mainly use are English and Hebrew. The spellchecker works for English but not with Hebrew. How can I add another language to the spellcheck?

    http://m10lmac.blogspot.com/2011/06/extra-spell-checking-dictionaries-for.html

  • How can we add additional fields to the BP Search RESULT screen?

    Dear Experts,
    How can we add additional fields to the BP Search RESULT screen so that the BP's being displayed in a search result show maintained values for the particular column/field?
    Thanks!!!

    Hi Laxman,
                           I got same requirement for ibase hierarchy.I want to add new fields in Ibase hierarchy AB.Do you have any idea regarding this.My requirement is that ,i want to dispaly a fields as a check box which display that this component is in under warranty or not by checking the box.Plz tell ,how can i add a new field in tree type context node.I add a new fields using AET ,but that is not available in that AB.
    Thanks
    Vishwas Sahu
    Edited by: vishwas sahu on Nov 17, 2009 1:51 PM
    Edited by: vishwas sahu on Nov 18, 2009 5:22 AM

  • How can i add Custom fields into the

    Dear Experts
    We have Ecc6.0 system,
    How can i add Custom fields into the Infotype Screen(PA30),i heard that we do it by PM01 Tcode.
    But in PM01 i am unable to find the enhance infotype tab.
    How can i do it ....pls help.....
    Regards
    Sajid

    Hi,
    Do it thru the third tab : Single Screen.
    There write down the infotype number (e.g. 0022) and say generate objects.
    Regards,
    Dilek

  • How can I open and listen to the PDF documents with audio in my iPad?

    How can I open and listen to the PDF documents with audio in my iPad?

    You need to use a PDF reader that supports multimedia. Adobe Reader 10.3 does not. Adobe has not stated whether it will support multimedia in the future.
    In the meantime, you could buy an application that does like PDF Expert. Read about it here:
    Finding the Best Tablet PDF Reader

  • How can I add sales TAX at the end of my calculations?

    How can I add sales TAX at the end of my calculations?

    We currently do not support adding sales tax.
    Randy

  • How can I add a linkbutton in the matrix (SBO 7.10.75)

    Hi ,everybody ,I want to add a linkbutton in a matrix ,and it's linkobject is If_PurchaseOder , but there are some errores ,and I don't know why .
    in the SBO2004B ,You can use
    set oLink=oColumn.ExtendedObject
    oLink.LinkObject=If_PurchaseOrder
    but in the SBO7.10.75 , oColunm has no such method.
    How can I do it ?
    thanks

    From the documentation of 2004a:
    Use the LinkedButton object to create a link to another object from a column with a link arrow.
    First, assign this object to a LinkedButton object and then use the LinkedButton object to link the column to the object you want.
    Example
    [Visual Basic] The following sample code shows how to add a column with a link arrow and link it using the ExtendedObject property.
    Dim oLink As SAPbouiCOM.LinkedButton
        Set oColumn = oColumns.Add("A", it_LINKED_BUTTON)
        oColumn.DataBind.SetBound("True","","linkDataSource")
        Set oLink = oColumn.ExtendedObject
        oLink.LinkedObject = lf_BusinessPartner

  • How can I add a logo to the bottom right of a video?  I have a jpg logo to use.

    How can I add a logo to bottom right of video, using a jpg?

    Even though David's answer is for Final Cut Express, the same answer should apply for FCP X only you would need to place the "track" ... let's say clip ... above the clip it is to overlay.  Thus it can either be a storyline or a connected clip but it should reside above the primary storyline assumming that is where the video is you want your logo to overlay.  As David points out, the type of graphic file should be one that allows the transparent background feature such as a PNG or PSD, etc.  Of course, if your logo has a solid box background, you may be able to simply scale it down and position it to the right place and overlay it over your other video clip using the method described above.  Hope this helps.
    stephen

  • How can I add jar files into the namespace in code?

    My friends:
    I need to add jar files into my namespace dynamicly in my code.But the jar files might be repeated, I am not sure.so, i wonder how can I add them into my namespace, ignoring the repeated files?
    This is my code:
    URL[] urlArrayA = new URL[5];
    urlArray[0] = sample1;
    urlArray[1] = sample2;
    URL[] urlArrayB = new URL[5];
    urlArrayB[0] = sample3;
    urlArrayB[1] = sample4;
    URLClassLoader urlClassLoaderA = URLClassLoader.newInstance(urlArrayA);
    URLClassLoader urlClassLoaderB = URLClassLoader.newInstance(urlArrayB);
    how can i visit classes in urlClassLoaderA from classes in urlClassLoaderB?

    could anyone please answer the question for me ? thank you...

  • How can I add action listener to a cell or row in a table?

    hi there
    I need to be able to click on one cell or one row in a table, and perform some action, like openning a dialog or something. how can i add listener?

    // See How to Use Tables in tutorial. You will get one idea about Table Renderer and Editors.
    // If u understand the concept, ur problem is very easy to solve by adding Editor to your column.
    "You can think of the renderer as a configurable ink stamp that the table uses to stamp appropriately formatted data onto each cell. When the user starts to edit a cell's data, a cell editor takes over the cell, controlling the cell's editing behavior.
    Here, While tabing thru the table row, default all cell editors are JLabels. (Not editables)
    So u can make it those cells are editable JTextFields or JComboBoxes based on the column while tabbing. And you can add Listeners to that fields too. So those editable fields are called Editor Components.
    // see javax.swing.DefaultCellEditor class for more description
    Here i am adding my own JTextField editor to 3rd column of a table by using
    mytable.getColumnModel().getColumn(2).setCellEditor(editor );
    Here editor is a obj of below class. (Not complete..class)
    public class JbuiEditor extends DefaultCellEditor implements // any listener {
    public JbuiEditor(JTextField tField) {
    super(tField);
    setClickCountToStart(1);
    tField.addFocusListener(this);
    this.editorComponent = tField;
    public Component getComponent(){
         return editorComponent;
    public Component getTreeCellEditorComponent(JTree tree, Object value,
                                  boolean isSelected,
                                  boolean expanded,
                                  boolean leaf, int row) {
         String StringValue = tree.convertValueToText(value, isSelected,
                             expanded, leaf, row, false);
         delegate.setValue(stringValue);
         return editorComponent;
    public Object getCellEditorValue() {
    return super.getCellEditorValue();
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,int row, int column) {
    super.getTableCellEditorComponent(table,value,isSelected,row,column);
    ((JTextField)editorComponent).setText(value.toString());
    //Here u can add any type of listener to this Editor component.like..
    ((JTextField)editorComponent).addActionListener(..);
    ((JTextField)editorComponent).addFocusListener(..);
    return editorComponent;
    Hope gives some idea.

Maybe you are looking for

  • Signatures on my I-pad?

    I have a sign off form that I use multiple times daily for customer signatures. Can I simply take a digital photo of it and then allow customers to sign in box via ipad?

  • First Time Capsule Backup Failed - Time Machine Error

    I bought my Time Capsule yesterday because I needed to backup my MacBook (which I bought 6 months ago). My plan was to backup the MacBook to the TC and then do an Erase and Install of my MacBook because of problems I'm having with the MacBook (it con

  • Aysnchronous Abap Proxy

    Hi Guys,     I have configured scenario for Abap Proxy(sync) to Abap Proxy(sync) and it is working fine. But when i try to run scenario involving asynchronous proxy no message is sent from corresponding business system.   Does any configuarion settin

  • Single row output

    Create table test_table ( metric_name varchar2(30), dt date, value number) ; insert into test_table values ('METRIC_1', to_date('12/31/2013 08:00:00','mm/dd/yyyy hh24:mi:ss'), 10) ; insert into test_table values ('METRIC_1', to_date('12/31/2013 09:00

  • My phone is locked. (N8)

    Well since I updated my phone to this Belle version, it has this security thingy which by accident i went in that and yeah its an anti theft and i didnt know how to exit so it just went on and it said that i have to reboot. i didn't and then after a