How to update JTable when clicking outside the table?

Hi
(Sorry if this has been asked before but I can't seem to see exactly how to do this from previous posts.)
I have a JTable which sits on a jPanel which itself is part of a frame.
When I click anywhere outside the table when I'm editing a cell in the table, how do I end the edit mode of the table (so that the cell is updated with the new contents).Currently I can only update a cell's contents during edit when hitting 'enter' or by clicking on another cell within the table.
It seems that the following code is used in the process but I'm sure that I'm still missing something:
if(table1.getCellEditor()!=null)
table1.getCellEditor().stopCellEditing();
If anyone out there knows how to do this,I'd really appreciate hearing how.
Thanks a lot
LGS

Thanks for your comments but I'm still having problems.
When I add the following code:
table1.addFocusListener(new java.awt.event.FocusAdapter()
public void focusLost(java.awt.event.FocusEvent evt)
if (table1.getCellEditor() != null)
table1.getCellEditor().stopCellEditing();
and then try to edit my table,as soon as I double click on any cell in the table,my setValueAt method in my Table Model is being called before I even edit the cells contents. The above code is in the same method in which I actaully create table1 i.e.createTable().
Can anyone help?

Similar Messages

  • Final Cut Pro 7: Audio Stops when clicking outside the program.

    Just something that annoyed me and was wondering if their is a way to correct it.  Whenever I am listening to a song within final cut in  a video or in the viewer, it will stop playing if I click out of the program.  For example i might be listening to a song and want to go do a google search or open another program and as soon as i do the audio stops.  It will begin playing once i click back into final cut and everything works fine but its just bothersome.  If anyone knows a way to change this please help me out!
    Thanks
    Josh

    well, I think if I remember correctly that might be a normal state, because FCP wants to "take over" completely. My systems are on MacPros with Kona Cards and I/Os setup for 5.1 output. I think I lose audio because the Kona wants only one app controlling it at a time. I'd have to be sitting in front of the box to figure it out. But oddly enough I'm actually home.

  • Af:popUp close when click outside popup area, Jdev 12c

    Hi! I had a similar post a long time ago and it became archived due to lack of time from my part, it was never answered
    the problem is:
    1)Popup without dialog tag: closes when a click is made outside the popup area.
    2)Popup with a dialog tag:  doesn't close when clicked outside the popup area
    I'd like to be able to let the user close the popup(with dialog) when he/she clicks outside the popup area.
    Thanks!

    User, which jdev version do you use?
    Why don't you use the popup without the dialog then?
    Can't be too hard to put some buttons ontp the popup.
    Timo

  • How to fire "table change" once click other regions outside the table erea?

    I have a JTable created with DefaultTableModel. Usually the edit behavior of table cell is like this:
    1) Select one cell, it is highlighted in blue.
    2) Double click the cell, it's made editable with white background.
    3) Two scenarios
    (a) Once finish edit, press "Enter", the cell background turns from white to blue. At the same time, the table change is "fired" .
    (b) Once finish edit, click another cell, the originall cell turns white, and the new-clicked cell is highlighted in blue. At the same time, the table change is "fired".
    4) While editing one cell, and click somewhere OUTSIDE the table area. In this case, the table change is NOT fired.
    [This cause a confusion, user sees the changed text in table cell, but actually it is not stored and will not be stored in the table.]
    So what I want to implement is: once click the region outside the table, the text in that editabe cell (where you are just editing) is stored and fired.
    Can you help me? Thanks in advance!

    sabre150 & other experts,
    [see background in my first message]
    User is still not completely satisfied with the current behavior, though "table changed" can be fired when clicking other controls(eg. buttons or checkboxes).
    If I click a panel region(instead of a particular control), the "table changed" can not be fired. However, it is expected.
    I guess the reason is:
    a panel doesn't has a focus. so when clicking panel, the focus is not "lost" to the table cell.
    Any hints?

  • I updated my Itunes the other day and now, when clicking on the itunes icon, the program does not open?? I have tried uninstalling and reinstalling, resetting the computer, checking permissions, running as adminstrator.. nothing is working?? Help!!

    I updated my Itunes the other day and now, when clicking on the itunes icon, the program does not open?? I have tried uninstalling and reinstalling, resetting the computer, checking permissions, running as adminstrator.. nothing is working?? Help!!

    Amazing steps you've done so far! The great news is this is very unlikely an issue with your iPhone.
    I've run into a similar issue lately as well. I narrowed it down to one song that was causing 30 songs not to sync. I removed the song from the sync list (unchecked it) and all 29 songs were able to sync.
    You may be running into a similar issue. This may be a problem with this version of iTunes, an issue with one song or a group of songs; hard to know for sure. It's important to narrow down and isolate the cause. Most imporantly get that music back on there!
    The way to narrow down the casue add just a few songs at a time (even 1, just to get that first sync finished). Manually syncing is what you'll need here.
    Plug in your iPhone, on the Summary screen (shows a picture of your iPhone, the iOS version, Restore iPhone....; etc). Under the Options area at the bottom choose to Manually Manage Videos and Music then choose Apply in the lower right. The music that's on your iPhone now should be removed from your iPhone now. You're now able to sync music manually.
    The link below explains how to drag the songs from the iTunes library on the computer on to your iPhone which will start the sync. Add just one song just to see if you can get 1 of those hundreds of songs on there. If you can, awesome! Keep adding until you find the song or group of songs that are causing this issue.
    http://support.apple.com/kb/HT1535
    Please let me know how things are going.
    Cheers!

  • How to Get the value when clicking on the link

    I had a problem with when clicking on the link.
    I need get the link value to the controller when clicking on the link.
    I am displaying the database columns in jsp using repeater in links.
    I am displaying the data like this:
    RED
    BLUE
    GREEN
    these are three links.when clicking on the link RED. RED should go to the controller.
    After getting RED to the controller i will get the RED value from the database.

    my requirement is like that only
    I have just given the example of emp and dept
    emp(empno,zone_group_id,zone_id,deptno,ename,emp_p_ind,last_update_datetime);
    dept_emp(empno,dept_no,loc,dname,sal_emp,grade,last_update_datetime);
    CREATE OR REPLACE VIEW emp_zone AS
    SELECT e.empno,
          (select zone_group_id from price_zone_group where rownum = 1) zone_group_id,
           d.loc zone_id,    
           d.grade,  
           d.last_update_datetime,
      FROM dept_emp d
          emp e
    WHERE d.empno=e.empno
       AND e.emp_p_ind = 'Y'
      WITH READ ONLY;
    Now
    my requirement is to get the data of emp_zone view and needs to store those data into some other temp table
    if any of the above base table got updated deleted or inserted then the view last_updatetime also will get updated but problem is why im not using base table
    direct because it is having huge data and it performance issue .i have to get the value on the basis of view only and using some logic

  • I want to do banners ,how can we do  when click the same button (next button)  it must show differen

    i want to do banners ,how can we do  when click the same button (next button)  it must show different images . cam any one help

    Check out my blog with samples on Edgehero.
    http://www.edgehero.com/articles/interactivity

  • I have a mac. Firefox prompts me to download updates, but when I authorize the download it looks as though it's starting, but never gets underway or finishes. How do I address this problem?

    I have a mac. Firefox prompts me to download updates, but when I authorize the download it looks as though it's starting, but never gets underway or finishes. How do I address this problem?

    Try the alternate and easiest way by downloading
    * getfirefox.com

  • How do you know when you have the latest software updates

    how do you know when yo have the lastest software updates on your older IPOD?  I just purchased on home theater to replace one, Samsung, I was assured that the system would run my IPOD.  I've sync'd my IPOD to my computer a number of times before the purchase and since.  Samsung is telling me that I need to update my IPOD.  My ITunes keeps telling me there aren't any updates out there.

    Read the top of the page I gave you the link to. The
    latest update that you do not have only added more
    support for the Shuffle. If you are not having any
    problems leave as is. If you have problems then
    download the update. It will ask you for your user
    ID. Once you install the updater, your computer will
    reboot.
    This is what it says at the download site.. iPod Software 1.0
    * iPod with video
    Everything is working fine Barb with the ipod but I was under the assumption that if an update is available, I should download it...

  • When clicking on the Finder icon in the dock the Main Menu grays out ... what's wrong ... how do I fix?

    Product: iMac, OS X 10.9.5 (13F34)
    Processor: 3.5 GHz Intel Core i7
    Memory: 32 GB 160 MHz DDr3
    Storage: 3.12 TB Fusion Drive
    PROBLEMS:
    1. When clicking on the Finder icon in the dock, the main menu grays out and the window with documents, applications etc., does not pop up.
    2. iMac is not showing up in iCloud.com and, not syncing with my MacBook Pro, iPad Mini and iPhone.
    This situation seemed to appear after doing updates on my iMac.
    TROUBLESHOOTING I'VE TRIED:
    1. rebooted,
    2. repaired permissions,
    3. booted in safe-mode and let the basic tests run then rebooted to normal mode. Afterwards, the problem seemed to be corrected, however, it re-appeared shortly thereafter and still exists.

    Go to the Finder's General preference pane and reset the New Finder windows show: option.  Try changing it to some other folder, try it and then back again.
    If that doesn't jump start it try moving the com.apple.finder.plist file from your Home/Library/Preferences folder to the Desktop, reboot and then reset the Finder preferences.
    For Mavericks and Yosemite go to your Home folder and use the View ➙ Show View Options menu to bring the this window:

  • I can no longer deselect by clicking outside the area

    When I select an area in Photoshop CS6, I can no longer deselect by clicking outside the area.  My tooltip displays the cross with the plus sign in the lower right to indicate I am in additive mode.  I can right click for a dropdown menu and choose "deselect" , but that is a drag that interrupts my thought flow and so annoys me.  I've tried going into preferences and making sure the cursor is "standard." I've reset my preferences. No caps locked, etc. What is going on?  More importantly, how can I make it so that all I have to do is click outside the selection to deselect it.  I'm working on a Mac, if that makes any difference. I'd appreciate any help here.  Thanks.

    I believe you have to have the selection mode set to New Selection in the tool options bar for that to work.
    Or Cmd+D to deselect.

  • How do I use the value of a table attribute outside the table?

    I have two tables that are master detail. But it might not be so obvious to the user before he knows how the page works that they are master detail. The tables are in separate showDetailItems in a panelAccordion and what I was thinking of was to show the value of one coloum in the selected row in the master in the text in the showdetail item that contains the detail table. But I can´t find the right expression to put into the accordion. How should the expression look like to get the value of an attribute in a table for use outside the table?

    Thanks for the suggestion but it doesn´t work. The first problem is that the page turns blank when I use that expression for the text in the showDetailItem and the second problem is that I don´t seem to be able to use the master table as a partial trigger. When I click edit in the partial trigger property I can´t shuttle the master table over to be a partial trigger to the showDetailItem even if the table has an id.
    Edited by: Atlantic Viking on Apr 2, 2009 6:24 AM
    Well I figured out how to come half way. I did the following things:
    1) Created an attribute value binding to the attribute I wanted to be shown in the showDetailItem
    2) Set the text property in the showDetailItem to this attribute value like this #{binding.attributeValue}
    To solve the problem I had with the partial triggers I continued like this
    3) Gave other components on the path from the showDetailItem to the master table id´s
    4) Clicked edit on the partial trigger property on the showDetailItem and was now able to shuttle the master table over to be a partial trigger.
    But I now got an other problem which looks like a bug. At first when I enter the page it looks fine but when I change focus in the master table to another row part of the showDetailItem containing the detail table disapears. The detail table still remains and works as it should but the part containing the text I tried to set above disapears and the text in the showDetailItem containing the master gets replaced by the text that was supposed to be in the showDetailItem containing the detail table. Any suggestions how to correct this are very welcome.
    Edited by: Atlantic Viking on Apr 2, 2009 6:59 AM

  • How to edit a particular row in the table ctrl when a push button is clickd

    Hi Experts,
    How to edit a particular row (except the Primary keys) after selecting it in the TABLE CONTROL when a
    push button is clicked in the table control.
    For Eg. If you have a push button say "Modify", the particular row what we select in the table control should be in a
    editable mode after clicking "Modify" Push button.
    Please help me out.
    Thanks in advance.

    Hey Ram,
    Thanks a ton.
    Its working fine...sorry for the late reply.
    The reason behind the delay is because i had modified my code as per your logic it worked fine but the thing is that the whole column was in editable mode but not a single row.
    For E.g  If i want to edit a particular row, first i select the row and then  click on "Modify" button. After i click on the button, the whole column gets in a editable mode including the one which i intentionally selected.
    Here, the solution is that you have to set a flag in PBO so that once it is done with PBO then it need not come back again after we click on "Modify" button.
    And one more query is that after you modify a particular row in the table control ( When it is in editable mode) and click on the "Save" button, it is not getting updated to database.
    To update the database, we need to select the row once again after modifying it and click on the "Save" button.
    Here, database is updating only when it is selected again. If it is not selected, it is not getting updated.
    If you have any alternative solution, then please help me out.( I hope i am clear with the question.)
    Thanks,
    Ananth.

  • How to update Jtable based on itemStateChanged in JComboBox?

    My bad... I originally posted this topic in the Java Programming forum before I found this forum. My apologies.
    Anyway, can someone help me out pls? I need to be able to update my JTable based on the selected item in the combobox. Unfortunately, my JTable doesn't update when I choose another item in the combo box. What am I doing wrong? I've read about TableModels but I'm not quite sure how to use it.
    my code:
    my_constructor()
    JComboBox cbdisease;
    cbdisease = new JComboBox();
    cbdisease.setEditable(false);
    cbdisease.setBounds(30,20,270,25);
    add(cbdisease);
    cbdisease.addActionListener(this);
    cbdisease.addItem("View All");
    //aside from "View All" that was previously added to the combo box
    //get the values from the database to fill the comboBox
    showDiseases();
    cbdisease.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent e)
    System.out.println(cbdisease.getSelectedItem());
    displayRules();
    }// end constructor
    method: showDiseases
    connect to DB and get D_Description (column in database)
    display D_Description in combo box
    public void showDiseases()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    rs = statement.executeQuery("SELECT DISTINCT D_Description FROM disease");
    //place D_Description in combo box
    while(rs.next())
    strDesc = rs.getString("D_Description");
    cbdisease.addItem(strDesc);
    conn.close();
    statement.close();
    } catch (SQLException sqle) {
    sqle.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    }//end catch
    }//end showDiseases()
    method: displayRules
    connect to DB and get the rules depending item selected in the combo box
    display the rules in a table
    public void displayRules()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    if(cbdisease.getSelectedItem().equals("View All"))
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease ORDER BY D_DiseaseCode, D_QuestionCode");
    else //query depends on the item selected in combo box other than "View All"
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease WHERE" + " D_Description = '" +cbdisease.getSelectedItem()+ "' ORDER BY D_DiseaseCode, D_QuestionCode");
    // Convert the result set into an array of Objects
    Object[][] rows = getObjects(rs);
    // These are the column headings displayed in the JTable
    String[] headings = { "Disease Code", "Description", "Question Code", "Question", "Action", "# of Arrows", "Arrow"};
    // Initialize a JTable with the rows of objects and column headings
    rulestable = new JTable(rows, headings);
    // Add the table to a JScrollPane to make it display nicely
    rulesScroll = new JScrollPane(rulestable);
    // Add the scroll pane to the container
    add(rulesScroll);
    rulesScroll.setBounds(30,80,720,380);
    conn.close();
    statement.close();
    } catch (SQLException sqle) {
    //sqle.printStackTrace();
    System.out.println(sqle.getSQLState());
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    }//end displayRules()
    method: getObjects
    public Object[][] getObjects(ResultSet rs) throws SQLException
    // Find out how many columns are in the result set
    ResultSetMetaData metaData = rs.getMetaData();
    final int colCount = metaData.getColumnCount();
    ArrayList rows = new ArrayList();
    Object[] row = null;
    while (rs.next()) {
    // for each row in the result set, put every column into a temporary Object array
    row = new Object[colCount];
    for (int a = 0; a < colCount; a++)
    row[a] = rs.getObject(a+1);
    // add the temporary Object array to the array list
    rows.add(row);
    // convert the array list to objects
    return (Object[][])rows.toArray(new Object[0][0]);
    }//end getObjects()

    Just pass the new data to a new TableModel object's
    constructor and then u can use this new table model in
    ur JTable constructor. that woud automatically update
    the table data.
    Cheers!
    Asimsir Asim, do you mean inserting
    DefaultTableModel rulesmodel = new DefaultTableModel(rows, headings);
    to my code?
    public void displayRules()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    if(cbdisease.getSelectedItem().equals("View All"))
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease ORDER BY D_DiseaseCode, D_QuestionCode");
    else //query depends on the item selected in combo box other than "View All"
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease WHERE" + " D_Description = '" +cbdisease.getSelectedItem()+ "' ORDER BY D_DiseaseCode, D_QuestionCode");
    // Convert the result set into an array of Objects
    Object[][] rows = getObjects(rs);
    // These are the column headings displayed in the JTable
    String[] headings = { "Disease Code", "Description", "Question Code", "Question", "Action", "# of Arrows", "Arrow"};
    // Initialize a JTable with the rows of objects and column headings
    rulestable = new JTable(rows, headings);
    // Add the table to a JScrollPane to make it display nicely
    rulesScroll = new JScrollPane(rulestable);
    // Add the scroll pane to the container
    add(rulesScroll);
    rulesScroll.setBounds(30,80,720,380);
    conn.close();
    statement.close();
    DefaultTableModel rulesmodel = new DefaultTableModel(rows, headings); //like this?
    rulestable.setModel(rulesmodel);     
    } catch (SQLException sqle) {
    //sqle.printStackTrace();
    System.out.println(sqle.getSQLState());
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    }//end displayRules()

  • Why do scaled and masked captivate swfs respond to clicks outside the mask? Can it be stopped?

    We load Captivate 3 SWFs at runtime into our own course player, with movieclip.loadmovie. Our player is built with AS2 and published to Flash 8. We publish our Captivate movies to the same specs. Our latest challenge requires scaling and masking the Captivate SWF.
    A click outside the masked Captivate still triggers a click as far as Captivate is concerned, and it throws up a “that’s incorrect” message. Specifically, it only happens when you click in a spot that has masked Captivate “behind” it. In other words, if there would be Captivate there if the mask was turned off, Captivate will respond even when the mask is turned on.
    Is there a way to make Captivate ignore mouse clicks outside of the mask? I think it must be responding to Mouse.onMouseDown() since normally a masked object won’t respond to clicks outside the mask.
    I’ve put together a small test file to demonstrate exactly what’s happening, and I’ve posted it here: http://www.tbgprod.com/_experiments/captivatemasktest/captivatemasktest.swf
    I’ve also uploaded the .fla file. It’s ony 50kb and it’s available here: http://www.tbgprod.com/_experiments/captivatemasktest/MaskTest01.fla
    You’ll also need the Captivate .swf file if you want to test locally. Here’s the direct link. Right-click and save target as: http://www.tbgprod.com/_experiments/captivatemasktest/DisplayProperties.swf
    My question is "how do I make Captivate ignore clicks outside the mask?"
    Many thanks,
    Todd S

    Even if anyone just has any knowledge of how Captivate 3 movies actually monitor the mouse, I'd be happy to hear it. In other words, can anyone confirm my hunch? If we knew the internal structure of the Captivate SWF would it be possible to clear and restore some function as the mouse moves inside or outside of the target area? Something like this:
    on mousemove {
         if mouse has crossed boundary to the outside {
              functionBuffer = container.whatever.whatever.function;
              container.whatever.whatever.function = null;
         else if mouse has cross boundary to the inside {
              container.whatever.whatever.function = functionBuffer;
    This would kill Captivate's mouse functions and then bring them back to life, as the mouse exits and re-enters the masked Captivate area. Two questions:
    1. If we knew the necessary whatever.whatever.function information, would this work?
    2. Does anybody know the necessary whatever.whatever.function information?

Maybe you are looking for

  • Why is it taking so long to down load a movie

    Why is it taking so long to down load a movie on apple tv and my iPad

  • IPod Shuffle 4th gen cannot play music and no lights but shows up in PC

    I've been using the iPod Shuffle 4th gen for almost 3 months since I bought it at September 2010. Since yesterday, my iPod hasn't been playing musics or showing up any lights, same thing when plugged to computer and it didn't showed up in iTunes neit

  • XML and XSD file to an internal table

    I had read a lot of thread  but i don't understand how to deal with xml/xsd in R3. I need someone that have a definite example for this escenary please. With OPEN DATASET took from the server XML and XSD file, and put it in two internal tables type s

  • Wrong calculation of TDS (With holding Tax)

    Hi Gurus, I have matained TDS rates as follows - CA - 1%(Basic), CB - 0.1 (sucharge), CC - 0.022 (Edu. Cess), CD - 0.011 (Sec.Edu.Cess). I have assigned these same codes for some of the vendors. For all the vendors it is calculating TDS as rates main

  • Hard drive is corrupt, no recovery mode.

    I can't get pat the startup screen and I've immediately jumped to the conclusion that my hard drive is corrupt. It won't let me boot up in safe mode, and I tried to go into recovery mode to find that it would not let me. When I pressed option at star