Catch a JList event, which JList is in a JTable

I have got a JTable and in its cells are JLists or JLabels (it depend on data)
Here is code spinnet:
DefaultTableCellRenderer ownRenderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
NERecordSet nyers = (NERecordSet)tData.getModel();
if (nyers.getValueAt(row, column).getClass().getName().equals("com.nextent.corridor.db.NERecordSet")) {
JList listCell = new JList();
listCell.setModel((NERecordSet)nyers.getValueAt(row, column));
listCell.setCellRenderer(ownListCellRenderer);
listCell.setForeground(Color.BLACK);
if (isSelected) {
listCell.setBackground(Color.blue);
else {
listCell.setBackground(Color.LIGHT_GRAY);
return listCell;
else {
JLabel lCell = new JLabel();
lCell.setToolTipText(tooltip);
return lCell;
I'd like to catch the event 'click to one of elements of JList' -> How can I do it? (I tried to add an event handler in the renderer (JList.addMouseListener()), but it was wrong)
other questions: I'd like to add tooltip to the elements of JList, but I can't
Please help me to solve these problems!
Thanks!
rflair

Try this:
listCell.addListSelectionListener(
    new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            System.out.println("value changed in JList: " + evt);
);Good luck!

Similar Messages

  • Jlist event handling problem

    i have jlist component which is displaying number of string items
    now my requirment is when ever i press a key like 'k' string item which starts with 'k' like king,konqurer should be selected ,how do achieve this??
    any body who have done this can enlighten me
    thanks in advance
    anil

    Hi,
    The following example should give you some ideas.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class KeyList extends JFrame
      private JList list;
      public KeyList()
        super( "List Key Listener" );
        DefaultListModel dlm = new DefaultListModel();
        dlm.addElement( "aardvark" );
        dlm.addElement( "bat" );
        dlm.addElement( "cat" );
        dlm.addElement( "ditch" );
        dlm.addElement( "elephant" );
        dlm.addElement( "frequency" );
        dlm.addElement( "graphic" );
        dlm.addElement( "hunter" );
        dlm.addElement( "internal" );
        dlm.addElement( "junk" );
        dlm.addElement( "kind" );
        dlm.addElement( "lemon" );
        dlm.addElement( "money" );
        dlm.addElement( "nothing" );
        dlm.addElement( "open" );
        dlm.addElement( "property" );
        dlm.addElement( "quirk" );
        dlm.addElement( "restaurant" );
        dlm.addElement( "stormy" );
        dlm.addElement( "tether" );
        dlm.addElement( "utility" );
        dlm.addElement( "verify" );
        dlm.addElement( "water" );
        dlm.addElement( "yellow" );
        dlm.addElement( "zebra" );
        list = new JList( dlm );
        list.setVisibleRowCount( 10 );
        list.addKeyListener(
          new KeyAdapter()
            public void keyTyped( KeyEvent ke )
              char c = ke.getKeyChar();
              DefaultListModel lMod = (DefaultListModel)list.getModel();
              boolean done = false;
              for( int j = 0; j < lMod.getSize() && !done; ++j )
                String s = (String)lMod.get( j );
                if( s.startsWith( String.valueOf( c ) ) )
                  list.setSelectedIndex( j );
                  done = true;
        JScrollPane sp = new JScrollPane( list );
        getContentPane().add( sp );
        pack();
      public static void main(String[] args)
        new KeyList().setVisible( true );
    }Regards,
    Manfred.

  • Catching external mouse event ??

    This is an old question written by imasud at [http://forums.sun.com/thread.jspa?forumID=3&threadID=140391]
    I which I know the answer
    In java, I have seen, mouse events are only triggered if we move mouse inside a container. But is it possible to catch a mouse event when mouse is not on our container? Example: - My java program is running. - I open notepad and drag mouse - Is it possible to send the event to my java program that mouse is dragged. I will really appreciate if any one can answer my question. Regards .
    My eventual goal is to implement copy paste thingy offered in lunix enviornment. Like if I drag mouse on any text, it should get copied.
    Thank u
    Imran
    "

    The new feature of the forums. Answering questions from the past.
    Let them know they weren't forgotten.
    In java, I have seen, mouse events are only triggered if we move >>mouse inside a container. But is it possible to catch a mouse event >>when mouse is not on our container? Example: - My java program is >>running. - I open notepad and drag mouse - Is it possible to send the >>event to my java program that mouse is dragged. ---------------------->>----------------- I will really appreciate if any one can answer my >>question. Regards .
    My eventual goal is to implement copy paste thingy offered in lunix >>enviornment. Like if I drag mouse on any text, it should get copied.
    Thank uHmm, very good question, I have no idea.
    Tune in next week for our second installmant of "Questions from the past."
    You answer guru - Steve

  • LV7: how to catch 'Value change' event for cursor position in XY graph?

    I try to catch an event when the cursor position of a graph's cursor
    changes. I created a reference for the cursor array and registered a dynamic
    event 'Value change' for it. The event does not fire when the cursor changes
    (either by dragging it with the mouse or by direct entry of a new value in
    the cursor's X or Y fields. In contrast, when I register e.g. the 'Mouse Up'
    event for the cursor array, the event IS detected.
    -Franz

    So this is the same behaviour as that of a regular control which also does
    not fire a 'Value changed' event when it gets updated by e.g. writing to a
    local.
    At least the cursor's behavior is consistent then...
    But unfortunately also the direct user interaction with the cursor's numeric
    field does not fire the event, which is NOT consistent.
    I was trying to catch cursor changes in my event loop and had used a 'Mouse
    Up' event of the graph indicator to look for cursor changes (whose last
    position I had kept in a local or shift reg). In order not to miss a direct
    user interaction in the numeric field I added the dynamic event 'Value
    change' to the same event case, but with no success, it missed the direct
    entry ...
    according to what you say this seems to b
    e a bug then...
    -Franz
    "Greg McKaskle" schrieb im Newsbeitrag
    news:[email protected]..
    > > I try to catch an event when the cursor position of a graph's cursor
    > > changes. I created a reference for the cursor array and registered a
    dynamic
    > > event 'Value change' for it. The event does not fire when the cursor
    changes
    > > (either by dragging it with the mouse or by direct entry of a new value
    in
    > > the cursor's X or Y fields. In contrast, when I register e.g. the 'Mouse
    Up'
    > > event for the cursor array, the event IS detected.
    > >
    >
    > The reason is that value change events fire when user action directly on
    > the control changes its value. They do not fire when other programmatic
    > value changes occur. If you are looking at a value change on the cursor
    > palette, user interaction with the numeric should fire it, but updates
    > due to cursor movement are more like programmatic updates.
    >
    > Additional events will likely be added in future
    releases, and these may
    > make it easier to catch cursor movement events on a graph.
    >
    > Greg McKaskle
    >

  • Catch the DFF event.

    We have a requirement where in for a list of values(say account number) we have to default a field in DFF to some value. We have created a new form personalization for this under validatation.
    Now the issue is whenever the user enters the account number value in the account field, soon after the entry the next field DFF(which is supposed to default accrding to the form personalization) pops up with the old values for the field, till the user saves the form, after saving the form we get the new required value..
    Can we catch the dff event so that while DFF poping itself it displays the new values?

    Hello,
    Don't be surprised to get no answer here, because you posted in the wrong forum. Here is the standalone Forms forum, and you'd better ask this kind of question in the E-Business Suite forum ;-)
    Francois

  • [JS/CS4/CS5] Catching a selection event in a ScriptUI interface.

    I've got this ScriptUI interface (javascript based), and now I wonder if it would be possible to change one of its button captions depending on whether anything is selected or not, in the active document (would also have to be updated if the user selects or opens another document).
    1. Is it possible to write event listeners for this?
    2. Would it be possible to include this in the same script as the rest of the Script UI interface code (that is, I'd prefer avoiding a separate file in the startup folder).
    3. What's the best source of information regarding events, which ones there are, and how to handle them in javascript?
    Andreas

    1. Yes. The selection events work well in my experience.
    2. Yes, you don't have to add them at startup. You can do something like:
    app.addEventListener("afterSelectionChanged", selectionChangedFunction);
    before you open your window. Remove the listener in the onClose event of the window. I think you'll have to have some error trapping in the selectionChangedFunction to deal with app.selection erroring after a document close or during a revert.
    3. See this thread for an extension that lets you see events as they're happening.
    Jeff

  • Need BOR & event which triggers after vendor master change.

    Hi all.
        Can you pls let me know the BOR & event which triggers after vendor master change. (Xk02). I used tcodes SWELS (evetn trace) , and SWEL and changed vendor adress using XK02. but I could not find any event or BOR in the trace. Pls help me out.
    Cheers,
    sam.

    Hi
    when we change the vendor details we dont have the event which is automatically triggered by the system so we create an zbusinessobject as subtype  for the vendor(LFA1)  as supertype.
    and create a new event in that z business object .
    change document for the vendor is KRED you can check it in the CDHDR table by giving tcode name.
    after finding changedocument object go to SWEC and create a newentry specifying your changedocumentobject name and BO name and event name and click on radiobutton onchange.
    and now you can check whether an entry is getting in swels or not when changing the vendoor details.
    Thanks.

  • Dynamic TaskFlow Gets Refreshed on Catching a Contextual Event

    Hi,
    I am using Contextual events in my application. I have 2 task flows in my parent page. One TF is raising an event and the other is catching it. As my catching TF is a dynamic TF, I have specified the event map in it only.
    Everything is working as intended only that my dynamic TF gets refreshed when it catches the event! I do not want that. I want to explicitly refresh any UI component that requires to be refreshed, not the whole TF.
    So is there any specific property of task flows that make it to refresh itself when ever it catches any contextual event?
    Also I have tried 'Refresh="ifNeeded"' and 'RefreshCondition="#{false}"' in my dynamic taskflow specification in the parent page but it does not make any difference.
    Regards,
    Rahul Saxena

    Rahul,
    there is no setting for this. If however the managed bean you setup for handling the dynamic region is in backing bean scope (or request scope) then chances are that the region is refreshed because the bean restes after the request (just assuming here). Yournot giving us much to chew on (no JDeveloper version, no implementation details etc. ) So its hard to provide further ideas. As a last resort, if you have a support contract, you can contact customer support with a test case
    Frank

  • Photos app on iPhone contains photos under Events which aren't in iPhoto on Mac

    Hi,
    When I open the Photos app on my iPhone 4S there are a series of "Events" which contain photos. None of these events are listed within iPhoto on my Mac and I can't find where it is taking the photos from. All the events are just labelled with a date, for example "17 Dec 2012", but I am unable to delete the photos from my iPhone and because they are not showing up in iPhoto I can't delete them from there!!
    Any suggestions?!?
    Thanks,
    Mark

    I figured it out if anyone else is having the same issue.  I had to manually kill the photo app and it updated the pictures I just added when I re-opened it.  

  • 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);
    }

  • Any event which is raised when we save Purchase order after creating a new?

    Hi
    I need to know any event which is raised whenever we save a purchase order after creating a new one. I know event 'change' of object type BUS2012 is raised whenever we change a PO. Please help in this regard.
    Regards
    Swetabh

    Create event doesnt exist in BUS2012.check if custom business object exists for this by using 'where used list',probably it may have created event.

  • How do I find an event which is triggered on line selection for ALV grid?

    Hi,
    I'm trying to find an event which is triggered when a user selects a row in the ALV grid. I want to add my own code in to add up the total values of selected lines, but can't find any event which will trigger my method.
    I found CLICK_ROW_COL but it's protected so when I try and add a method for it:
      PROTECTED SECTION.
        METHODS:
        select_row
            FOR EVENT click_row_col OF cl_gui_alv_grid.
    I get the syntax error:
    Access to protected event "CLICK_ROW_COL" is not allowed.
    Am I using the right event? Am I implementing it correctly?
    Any help appreciated. Thanks in advance.
    Gill

    I chose to solve this by removing the line select buttons from the ALV and replacing them with a checkbox defined as a hotspot.  I then used EVENT hotspot_click FROM cl_gui_alv_grid to highlight the line and change my totals on a single click.

  • How to copy elements from one JList to another JList?

    I have 2 JLists. availableList and selectedList.
    String availableData [] = {"A","B","C","D","E","F"};
    JList availableList = new JList(availableData);
    JList selectedList = new JList();
    Now on 'Copy >>>' action I want the elements from availableList to be copied to selectedList (elements in the first JList should not be removed.)
    on actionPerformed I used: selectedList.setListData(availableList.getSelectedValues()) but it is adding only one element at a time.
    Can anyone help me in solving this problem? I want the elements from availableList to be copied to selevtedList and the duplicate should not happen. No need to sort the selectedList. just adding one by one.
    Thanks in Advance!
    Edited by: DeepakKotla on Oct 9, 2007 5:25 PM

    You might want to use a model to make it easier to add and transfer data
    like using DefaultListModel.

  • How to aggregate all events which lead to occurence of a complex event?

    Hi there,
    Is it possible to aggregate all the events which lead to occurence of a complex event in this complex event?
    Let's say we have six simple events
    id    amount    groupId
    1     1         1
    2     0         2
    3     1         1
    4     1         2
    5     2         2
    6     1         1The definition of the complex event is
    select sum(amount), groupId from myStream[range 20 seconds slide 20 seconds] group by groupId having sum(amount) = 3Consider I have the following class for my complex event:
    public class ComplexEvent {
        private int groupId;
        private int amount;
        private List<SimpleEvent> events;
        // getters and setters
    }Is it possible to have two complex events:
    ComplexEvent1 = {groupId=1, amount=3, events=[{id=1, amount=1, groupId=1}, {id=3, amount=1, groupId=1}, {id=6, amount=1, groupId=1}]}
    ComplexEvent2 = {groupId=2, amount=3, events=[{id=2, amount=0, groupId=2}, {id=4, amount=1, groupId=2}, {id=5, amount=2, groupId=2}]}How can we achieve it?

    Hi,
    I have blogged an example solution to this type of use case since it is a common scenario in CEP applications:
    http://blogs.oracle.com/CEP/2010/08/enriching_complex_events_with.html
    There is not currently out-of-the-box support for paging events to disk storage. If you truly have more events than can fit into the Java heap, you could try persisting the events to the database or to a data grid, such as coherence, and then joining with the database or cache to create the complex event containing the causal events.
    Another approach is to horizontally partitioned the stream of incoming events across multiple servers.
    Regards,
    Seth

  • Catch several key events

    hi...how do i catch several keys events?
    Example:
    i have a menubar with a menuitem Pan and need to catch the keys UP,DOWN,RIGHT,LEFT.
    I know how to catch one key using a menushortcut.
    Thanks.

    Like this :
    menubaritem.addKeyListener(new KeyListener(){
       public void keyPressed(KeyEvent evt){
          int keyCode = evt.getKeyCode();
          switch(keyCode){
             case KeyEvent.VK_UP:
                //your code here...
                break;
             case KeyEvent.VK_DOWN:
                //your code here...
                break;
             case KeyEvent.VK_LEFT:
                //your code here
                break;
             case KeyEvent.VK_RIGHT:
                //your code here
                break;
       public void keyTyped(KeyEvent evt){}
       public void keyReleased(KeyEvent evt){}

Maybe you are looking for