How to retrieve Data in a JTable, When you click on the specified line?

I Have a JTable. When I click on a line, I want to retrieve the value of the last column of the selected line.
I do that:
int selectedRow = lsm.getMinSelectionIndex();
int selecRow = lsm.getMaxSelectionIndex();
String res="";
if (selectedRow == selecRow)
System.out.println("number of colomns="+nbCol);
indiceDoc=(String)(data[selectedRow][1]);
res = " Row "+selectedRow + " selected"+"Indice =:"+indiceDoc;
else res = " Rows "+selectedRow + " to "+selecRow + " selected";
When the table is not sorted, it's ok, but when I sort one or more colomns, it don't return the correct value. It returns the value of an other line.
"Data" is my original table, but I think that it don't change when sorting.There is the Problem I thinK.
I think its because the index of the lines is reinitialize after each sorting.
Do you have an Idea?

The problem seems to be the sorter. You will have to ask the sorter for the sorted row number.
I have modified my TableSorter with a new method:
public int getJTableRowToModelRow(int index) {
     return indexes[index];
So in my class which holds the tablemodel, table & sorter if I want to get hold of an row I write:
int selectedRow = table.getSelectedRow();
int sorterRow = sorter.getJTableRowToModelRow(selectedRow);
Object data = tableModel.getData(sorterRow);
tableModel.getData(int row) is an added method to the tablemodel. It only, in your case, returns data[row][1];
I hope this wasn't to messy for you... ;-)
//David

Similar Messages

  • How to sort data in descending order when user clicks on the column heading

    Hi
    I have a report called "Top customers", which shows the top customers for a specific product line. It displays the customer name and one column with the total amount spent in the period for each product line. By default, the leftmost product line is sorted in descending order.
    If the user wants to know who are the top customers for another product line, they simply click on the column heading to sort the list by that column.
    The problem is that when you click for the first time on a sortable column heading, Apex sorts it in ascending order; you need to click on the same column heading again to sort in descending order.
    Is it possible to change this behaviour and sort the data in descending order in the first click? So the users don't have to click twice...
    Thanks
    Luis
    PS: Apex 3 running on Oracle 10.2.0

    Luis,
    See: Can I "catch" a click on a sortable column header of a report?
    Take a look at Anton Nielsen's answer with regards to hiding a column and displaying its value instead of the sortable column.
    Asumming the following simple report query:
    select product,sales
    from <table>
    Change that into:
    select product
    ,sales*-1 as reverse_sales -- Select this one as an extra column
    ,sales -- Hide this column
    from <table>
    In your report column attributes (of column reverse_sales), html-expression, type #sales#. It then displays the normal sales. However apex will generate a 'order by 2 asc' for the first time. The '2' will refer to the sales*-1 value: sorting it asc, is the same as sorting sales descending...
    Toon

  • Where does it go when you click on the Calendar icon beside the date field?

    Hi,
    Does anybody know what page or region does it go when you click on the Calendar icon beside a date field? I need to know how it generates the list of values for year.
    Need your help. ASAP. If you need to know more about my inquiry please email me, [email protected]
    Thanks.

    It's a Date bean and it is UIX which generates the java script to pop open the dialog box and the UI. I donot think there will be any public document available on the implementation.

  • How do I access recorded meetings? when I click on the 'meetings' tab it says I don't have permission

    how do I access recorded meetings? when I click on the 'meetings' tab it says I don't have permission

    Meeting recordings will have a direct URL, just like meeting rooms and content within Connect. You likely not a member of the Meeting Host group or Admin group within that Connect account, so you don't have the permissions to access the Meeting Library.
    You will either need the Host of the meeting room that you are looking for the recording of to get you the link, and insure you have the correct permissions to view it, or have them move the recording to the Content Library where it can be placed in a folder that you have permissions to view.

  • Please help. My facebook app will not open on my iphone 4. I deleted it,numerous times and downloaded it again. It uploads, but when you click on the icon, it flickers then closes.  Help.

    Please help. My facebook app will not open on my iphone 4. I deleted it,numerous times and downloaded it again. It uploads, but when you click on the icon, it flickers then closes.
    Help.

    Then the next step would be to restore your phone.  My advice is that prior to restoring you import your photos and videos to your computer and back up your contacts (by syncing them with iCloud or to a supported program on your computer using iTunes) as a number of users report losing these when restoring their device.

  • I'm on a website that usually when you click on the open chat(popup) link it opens a certain now, but now they are opening maximized all the time. How do I get them to open the proper size?

    It was opening the proper size and now it doesn't

    Works normally for me. The script that runs when you click the link will check to see if it already opened a window and try to switch to it, but if you are starting from scratch, this shouldn't be an issue.
    There probably are quite a few add-ons that affect popup window behavior. To see whether an add-on could be responsible, you could test the page in Firefox's Safe Mode.
    First, I recommend backing up your Firefox settings in case something goes wrong. See [https://support.mozilla.com/en-US/kb/Backing+up+your+information Backing up your information]. (You can copy your entire Firefox profile folder somewhere outside of the Mozilla folder.)
    Next, close Firefox, hold the Shift key, then restart Firefox. You will get a [https://support.mozilla.com/kb/Safe+Mode Safe Mode dialog]. Just click "Continue in Safe Mode" and do not "reset" anything just yet.
    If the window displays at the specified size in Safe Mode, one of your other add-ons (especially in the Extensions category) may be overriding it.

  • Since the last update, I cannot attach a file to my email in MobileMe. It has always worked until the latest update. Now, nothing happens when you click on the paper clip icon and 'choose' the file to add.

    I am using MobileMe on my Mac. Until the last update a few days ago, Firefox always allowed me to attach files to my emails. Now, when I click on the paper clip, and it takes to me find the file I want to attach, and I highlight the file I want to attach and click on 'open', nothing at all happens. the screen just goes back to my email. It always worked before, it does not now. It DOES work on Safari but I hate Safari, i want to use firefox.

    Hi satorilori-
    You might try this:
    -> Clear Cookies & Cache
    https://support.mozilla.com/en-US/kb/Template:clearCookiesCache
    -> Clear the Network Cache
    -> Reload web page(s) and bypass the cache.
    Press and hold Shift and left-click the Reload button.
    Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    Press "Cmd + Shift + R" (MAC)
    Check and tell if its working. Hope that helps!

  • Firefox stop responding when you click in the window.

    If you click anywhere in the content window the program stops responding. Title bar does not display "not responding". Can access menu function sometimes, but most of time program hang as soon as you click in the window.
    This problem started on 3/2/13 when the program was updated.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • How can I remove the list of 20 recently saved items when you click on the arrow on the far right side of the File Name screen for images, web pages, ect?

    When I right click and go save image/page/ect as the file save popup screen appears and on the right side of the File Name bar there is an arrow. If you click the arrow it shows the last 20? items that have been saved and their save location. Is there anyway to not have the list of recent items there or at the very least a way to clear them? I'm running Firefox 17 on Windows 7.
    Also when you save items as you were typing in the name you want to save them as it used to show filenames with the same name as you type that are saved in that directory so instead of typing the whole filename or copy/pasting you could start typing a filename and then hit the up or down arrow, backspace and just change the end of the filename without having to retype the entire filename.
    Hopefully you understand what I mean and can help me fix it, thanks.

    It's in the proper directory. I can scroll down the window on the right and see the files but if I start typing the file name of one of them the autocomplete drop down thing that shows matching file names does not appear. In the back of my mind I'm starting to think a setting got changed and then the list of matching file names stopped appearing but I can't recall what setting may have been changed, if it was a firefox or microsoft change or for certain if anything got changed at all. Yeah I know I'm not helping my own cause but what can you do.

  • HT3529 OS X Mountain Lion Messages - after receiving picture in texting, when you click on the picture of enlarge and then close that window to go back to texting, the picture disappears.

    In OS X Mountain Lion Messages, after receiving a picture in a text, when I click to enlarge the photo for viewing and then close that window and go back to texting, the photo is gone from the text.

    In OS X Mountain Lion Messages, after receiving a picture in a text, when I click to enlarge the photo for viewing and then close that window and go back to texting, the photo is gone from the text.

  • When using Yahoo mail my contacts are there one minute and when you click on the they all go away and it says you have no contact

    The TO box used to auto fill when I started typing if an address was in my Contact list. The + at the end of the area for an email address says I have no Contacts
    With Firefox, Yahoo Mail works normally except for contacts, when I click "Contacts" I get a screen with no names listed. If I start a new eMail and click "To" the listing appears as normal.
    When I launch Yahoo Mail from Internet Explorer, the "Contacts" tab works normally.

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!

  • I lost the tool bar in my email, how do I get it back, and how do you get the link to open when you click on the little chain link symble

    I work on a Dell with Windows XP and Firefox 5, and when I send out an email and try to type a link in the body of the email the link does not open up for the addressee, and I highlight the link and then bold it, and the go to the little chain link symbol and clink on it and no matter how I fill out the boxes it will still not open when they get the email. What do I have to do to get it to work, please help, my email is [email protected] , and the link that I unusually send out is '''[[www.PaidonBillsNow.com |www.PaidonBillsNow.com]]''' now this was different than what is normally comes up, but how do I get this to work, thanks my email is [email protected]

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode

  • How do you post photos from iPhoto to Facebook if when you click on the F icon the "publish" button is not active?

    When I want to share a photo from iPhoto and post to Facebook, the publish button is grayed out.
    Already checked privacy settings on FB and nothing should be blocking this.

    iPhoto menu across the top.  mouse up there if you are in full screen mode>Share>Facebook  log in with your info
    you have to select at least one photo to have active dropdown window under Share

  • HOw to find out a report name when you know only the name of background job

    Hi experts ,
    my question is i need to find out teh report name for which i knew only the background job name of the report .
    thanx
    Venky.

    Go to tcode SM37->Give job name and execute->choose tool bar button STEPS (Disply Steps list) ->Then you will get program or command

  • The search suggestion drop box doesn't allow you to go on the web when you click on the suggestion.

    When I type in a search word in the search box, the dropdown menu of suggestions doesn't allow access onto the web.

    Try Enter Selects: https://addons.mozilla.org/en-US/firefox/addon/7423/
    You can just start typing in the Location Bar, and press Enter to go straight to the first match.
    '''Other issues:'''
    Your are running an out of date Firefox that is potentially vulnerable to malware. Please consider upgrading using Tools -> Check For Updates or downloading and installing from http://www.mozilla.com/en-US/firefox/all-older.html
    Your plugins are out of date and also potentially vulnerable to attacks from malicious web sites. Consider getting them all updated with Plugin Check: http://www.mozilla.com/en-US/plugincheck/

Maybe you are looking for