How to catch the mouse event from the JTable cell of  the DefaultCellEditor

Hi, my problem is:
I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
Any idea will be highly appreciated!
Thanks in advance!

Hi, bbritta,
Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
Thanks.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test3
extends JFrame {
// JTextField jtf = new JTextField();
Object[] as = {"aa","bb","cc","dd"};
JComboBox box = new JComboBox(as);
public Test3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
String[] head = {
"One", "Two", "Three"};
String[][] data = {
"R1-C1", "R1-C2", "R1-C3"}
"R2-C1", "R2-C2", "R2-C3"}
JTable jt = new JTable(data, head);
box.addMouseListener(new MouseAdapter() {
// jtf.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
System.out.println("-------------------JComboBox mouseclick....");
jt.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
System.out.println("-------------------JTable mouseclick....");
// jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
content.add(new JScrollPane(jt), BorderLayout.CENTER);
setSize(300, 300);
public static void main(String[] args) {
new Test3().setVisible(true);
}

Similar Messages

  • How to catch menu click events from B1AddOn Wizard

    Dear Friends,
    I'm adding some custom menus to the SAP BO main menù using B1 Addon Wizard generated code, but then I don't know how to catch the events generated by the menus.
    Thank you for attention
    Massimo

    Thank you Eddy,
    I had a look at the help, but there it is not explainsed that events can be attached only to string menus!!
    It was attempting to do something wrong.
    A further question: is it possible to add new menus and related events to an existing project (I tried with new item and then B1 Addon Component, but it doesn't let me add new menus)?
    Thanks again
    Masimo

  • How to throw the mouse event to a upper level component?

    For example: a panel using absolute layout, and there is a label on it.
    Now when mouse clicked on the label, i do not want the label but the panel to get the mouse event , so that i can get the mouse click point's x and y in the panel.
    How to implement it?
    Thanks a looooooooooooot for ur help
    Best Regards

    try this
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setSize(100,75);
        setLocation(300,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final JPanel p = new JPanel();
        JLabel lbl = new JLabel("Click Me");
        lbl.setToolTipText("OK");
        lbl.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        p.add(lbl);
        getContentPane().add(p);
        lbl.addMouseListener(new MouseAdapter(){
          public void mousePressed(MouseEvent me){//match method name
            p.dispatchEvent(me);}});
        p.addMouseListener(new MouseAdapter(){
          public void mousePressed(MouseEvent me){//with this method name
            System.out.println("Panel clicked");}});
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • How to deal with the mouse events when the thread is running

    Hi everybody,
    I have a problem with my program.
    Now I want to present a picture for some time in the Canvas,then automatically clear the screen, but when the user press the mousebutton or keybutton, I want to stop the thread and clear the screen.
    How can I receive the mouse event when the thread is running?
    Thanks,

    I use my code in a GUI applet.
    I try to use the code tag, it's the first time.
                   Image im=sd.getStimulus(obj);
                   if(pos==null){
                        g.drawImage(im, (w-im.getWidth(null))/2,(h-im.getHeight(null))/2,null);
                   }else{
                        g.drawImage(im, pos.x,pos.y,pos.w,pos.h,null);
                   try{
                        sleep(showtime);
    //                    Thread.sleep(showtime);
                   }catch(InterruptedException e){}
                   if(pos==null){
                        g.clearRect((w-im.getWidth(null))/2,(h-im.getHeight(null))/2,im.getWidth(null),im.getHeight(null));
                   }else{
                        g.clearRect(pos.x,pos.y, pos.w, pos.h);
                   }

  • I have an ipad mini, how can i bring in to the ical, events from my yahoo and google calendars

    i have an ipad mini, how can i bring in to the ical, events from my yahoo and google calendars

    You might ask at the iPad forum, the forum here is for developers of software.
    https://discussions.apple.com/community/ipad/using_ipad

  • How to remove all the cleaup events from DBA_AUDIT_MGMT_CLEAN_EVENTS

    Dear gurus,
    how to remove all the cleaup events from DBA_AUDIT_MGMT_CLEAN_EVENTS
    Arun

    Hi,
    Take a look:
    http://www.morganslibrary.org/reference/pkgs/dbms_audit_mgmt.html
    Regards,

  • Iocane: poison the rodent (simulate X11 mouse events from keyboard)

    Iocane: the colorless, oderless, tasteless poision that will rid your system of its rodent infestation.  Though no promises about its effectiveness against Rodents Of Unusual Size.
    Iocane simulates mouse events from the keyboard.  Iocane can be passed a few parameters which - ideally - could each have a key binding in your favorite window manager.
    If iocane is called with no parameters it starts in interactive mode (which currently lacks documentation ... hey, I just wrote this this morning).  In interactive mode the directional arrows or h/j/k/l keys move the mouse cursor.  The number keys simulate button presses (1 = left button, 2 = middle, 3 = right).  The page up and page down keys simulate mouse wheel activation.  "q" quits from interactive mode returning any grabbed keys to their normal behavior.  Key bindings are all controlled from a simple rc file.
    Iocane can also be passed a series of commands on the command line or the filename for a script file with a list of iocane commands.  Iocane can also read command from its standard input.
    Iocane is conceptually similar to some functions of xdotool, but iocane should work under any window manager (or no wm at all), is much smaller, and the interactive mode allows for a sequence of many actions without the program having to start up and close down many times in rapid succession.
    Please report bugs or feature requests here.  Iocane is currently 127 lines of C, and it will remain small; in other words, features will only be added if the can be added without substantially increasing resource use.
    EDIT: Version 0.2 is now in the AUR
    Last edited by Trilby (2012-11-03 02:23:15)

    Any arbitrary number of buttons should be easy enough to simulate - provided the Xserver actually responds to events with that button number.  An update I'll push to github tomorrow will include a few changes, including buttons 1-9, but if there is need/desire I could increase that.  Sticking to 1-9 allows for the computationally cheaper hack of converting a string to a number by simple substracting 48 from the value of the first character; numbers greater than 9 would require the use of atoi() or some funky conditionals.  In the grand scheme of things this is fairly trivial, but unless there is a real reason to use more than 9 mouse buttons I'd prefer to keep the lighter code.
    Passing a window name and getting it's coordinates is possible but after considering it I've decided it wouldn't fit well in iocane.  The reason being that to do a half-arsed job of it would be pretty easy.  To do it properly, however, it would take quite a bit of scanning through recursive calls to XQueryTree, polling atoms/wmhints, matching strings, checking for subwindows in the case of reparenting window managers, and a bunch of other nonsense ... all to get two coordinates.
    However iocane will play nicely with any tool that will provide those coordinates from a given window name, so I can imagine and invocation such as the following to move the mouse 10 pixels right and down from the top left of a window - lets call it FlamingSquirrel - and simulate a click there:
    iocane $(cool_app FlamingSquirrel) : move 10 10 : button 1
    Currently that could only be done from a command line invocation, not from a script or interactive session, as it requires shell processing for the command substitution.  I can add support for this type of invocation in scripts and interactive mode as well.  Then all you need to do is find (or write) a program that will give coordinates for a window given a title/name.  I suspect such a program probably exists out there, or if you are comfortable with C, I could give you the starting framework for it as I made something that would have much code in common for another task on these forums (it's in jumpstart.c in the "misc" repo on my github).
    In fact, you could use the following
    xdotool mousemove --window FlamingSquirrel 0 0 && iocane offset 10 10 : button 1
    Though if you are using xdotool anyways, I'm not sure if iocane would serve much of a purpose, unless you just prefer iocane's syntax.
    Last edited by Trilby (2012-11-01 00:21:14)

  • ALV Grid editable - How to raise the data_changed event from outside object

    Hi,
    i'd like to like to raise the data_changed event from outside the ALV-Grid object in order to display errors to the user.
    For example a new row was inserted within the program. The user has only to complete the missing informations. Before saving the transactions the program has to execute some semantic checks. The errors of this check process should be shown to the user by creating an instance of the cl_alv_changed_data_portocol object.
    Thanks.
    Regards

    You don't need to raise the data_changed event to perform the edits or to issue messages using cl_alv_changed_data_protocol.
    The following assumes you have an ALV grid object g_alv based on the CL_GUI_ALV_GRID class.
    You can mark the inserted records upon insertion as selected using the set_selected_rows method, and then retrieve these rows later using get_selected_rows and perform necessary edits.
    Save the row number of each inserted row into a table of the appropriate type (see the method definition for this):
    DATA: t_index_rows    TYPE  lvc_t_row.
    DATA: s_row_no        TYPE  lvc_s_roid.
    DATA: t_row_no        TYPE  lvc_t_roid.
    Load entries into t_row_no after each insert.  Capture the row number and save in the table t_row_no.
    e.g.
    PERFORM insert_row USING s_row_no-row_id.
    APPEND s_row_no TO t_row_no.
    FORM insert_row would have whatever code you are using to insert the row.  Save the row id into s_row_no-row_id (which is an INT4).
    When done with all inserts do the following
      IF t_row_no[] IS NOT INITIAL.
        CALL METHOD g_alv->set_selected_rows
          EXPORTING
            it_index_rows            = t_index_rows
            it_row_no                = t_row_no
            is_keep_other_selections = 'X'.
      ENDIF.
    Then, if SAVE is pressed without the data_changed event having been raised (such as if the user just pressed SAVE without changing anything), use method get_selected_rows to retrieve the rows that were inserted and perform the necessary edits.
      DATA: l_t_rows    TYPE lvc_t_row.              " ALV control: Table rows
      CALL METHOD g_alv->get_selected_rows
        IMPORTING
          et_index_rows = l_t_rows.
    Loop through l_t_rows and use the row as an index into the grid, perform the necessary edits, just as you would if the data_changed event had been raised.
    If any edits fail, then send messages to the user, abort the save, and re-display the grid.
    Remember to refresh the t_row_no and t_index_rows tables if you load a new data set.
    You can also use a similar technique with the data_changed event to mark each changed row as selected by saving the row ids, and then you only have to update the changed rows on SAVE, which can minimize database I/O.
    Good luck.
    Brian

  • How can i print my files from mi iphone 5 throught the airport express?

    How can i print my files from mi iphone 5 throught the airport express?? i have the last iOS version installed and also the last firmware version of the printer. the printer is already connected to the USB airport express and when i look for printers in airprinter there is no printer found. i have an HP LASERJET P1606dn(i think that is supported by the airprinter).

    In order to function with AirPrint, a printer must connect to the network wirelessly.
    Even if you have an AirPrint compatible printer, iOS devices will not be able to print to the printer when it is connected via USB.
    So, you have two options:
    1) Reconfigure the printer to connect to the network using wireless only and the iOS devices should be able to print that way....assuming that you have up to date drivers for the printer installed.
    2) Leave the printer connected via USB and then use a third party App like Printopia installed on your Mac as a "workaround" to (hopefully) allow the iOS to device to be able to print.  If you want to give this a try, there is a free trial for Printopia, so you will know if it will work before you buy. You must have a Mac running on the network in order for Printopia to function correctly.
    Printopia - AirPrint to Any Printer - Print from iPad - Print from iPhone ...

  • HT4528 how do I create an event in my calander that repeats the second thursday of every month

    how do i create an event in my calander that repeats the second thursday of every month

    This should get you started down the pathJust replace User data with your cluster and do the data integrity check in the value change event use a simple one button dialog to notify the user which values are out of compliance and disable and grey the OK button untill all conditions are met.
    Jeff
    Attachments:
    Prompt(Date).vi ‏50 KB

  • In my old OS I could press F11 and clear all the open windows from view to see only the desktop. How can I do that now in Mavricks?

    In my old OS I could press F11 and clear all the open windows from view to see only the desktop. How can I do that now in Mavricks?

    system preference > Keyborad >  click the box thast says  use all f1,f2,f2 keys as standard functiong Key and then the f11 key should casue all window fo fly to the side and you can see your desktop

  • How do I control my mac from another mac not in the same network?

    How do I control my mac from another mac not in the same network? Thanks

    You can do it manually, but it is much simpler if you use a tool such as Back To My Mac, LogMeIn, or something like that. Those programs enable you to connect to your computer through your router without you having to adjust the router settings manually.

  • How do I transfer document files from my hp laptop to the windows partition side on my macbook pro?

    How do I transfer document files from my hp laptop to the windows partition side on my macbook pro?

    Windows LAN file sharing, usb thumb drive, external hard drive, online cloud file sharing service, email attachments, ...

  • I have a seagate 1tb hard drive and a 16gb memory stick, how do i transfer avi files from one to another as the click drag and drop wont work, please help?

    i have a seagate 1tb hard drive and a 16gb memory stick, how do i transfer avi files from one to another as the click drag and drop wont work, please help?

    Greetings,
    What happens when you drag it?
    Make sure the drive you are moving the files to has enough available space to receive the file:
    Click on the movie file and go to File >  Get Info and note the "size"
    Check the drive to which you are moving the file to make sure it has enough available space: https://idisk.me.com/madisonfile-Public/web/finder-drive-available-space-and-for mat.html
    Also note the format of the drive you are copying too.  If it is not Mac OS Extended or FAT (not recommended unless you are taking it to a windows computer) then that may be the issue.
    Hope that helps.

  • HT201269 I restored my iphone and now it has gone back to factory settings. How do I transfer all the purachsed items from my itunes back onto the phone?

    I restored my iphone and now it has gone back to factory settings. How do I transfer all the purachsed items from my itunes back onto the phone?

    Hello whytea4
    Check out the articles below and choose the one for your computer to sync media and apps to your iPhone.
    iTunes 11 for Mac: Set up syncing for iPod, iPhone, or iPad
    http://support.apple.com/kb/PH12113
    iTunes 11 for Windows: Set up syncing for iPod, iPhone, or iPad
    http://support.apple.com/kb/PH12313
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

Maybe you are looking for

  • Is there any way to create multiple users in a single shot in oracle db

    Can Any one tell me, is there any way to create multiple users in a single shot in oracle database.

  • IPhoto takes 30 minutes to open

    Each time I open iPhoto 11 it takes around 30 minutes to open. I just see a blank window with the spinning icon. I have my photos stored on an external drive. To test, I started a new library on a new external drive because the other one was about fu

  • Showing messages as URGENT

    I need to show some of my messages as URGENT for recipients all of whom are -- I regret to say -- using Microsoft Outlook, and some of whom need some extra prompting to take the 'Urgent'-marking seriously. I should like simply to be able to mark the

  • To print the Smartforms in Hindi

    Dear All, My latest requirement is to print the Smartforms in Hindi. Can anyone please guide me through this? Thanks in advance. Regards, Sourav

  • Incredible 2 will not charge.

    I have a Incredible 2. I literally purchased it 1 year to the day.  It will not charge at all.  I've tried everything I can think of.  we have drained it completely, we have left it plugged in for hours.  It simply won't charge at all. What are my op