Only allow x rows to be selected in a jtable

hi all,
i want to only allow a user to select x rows. where x is set in the code.
for example if i only allow 2 rows to be selected....and the rows are:
a
b
c
d
e
then if the user selects a then b then c the selection is first ab, then bc (ie a is deselected when c is selected). kind of like a first in first out thing.
so if the user then selected e, then you have c and e as the selected rows.
any ideas of how i can do this...thanks everyone.
Message was edited by:
sand_samurai

A JTable's row selection is handled by a ListSelectionModel object:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTable.html#selectionModel
You should be able to either use manipulate that object, or subclass it to implement you custom selection logic and assign your subclass to the table's selectionmodel.
As far as implementing the logic, keep a queue of the selected rows. When a new row is selected, add it to the queue, and then reset the selection to the first x rows in the queue.

Similar Messages

  • Why iPhone only allows sync ALL contacts, not selected groups?

    THE OBJECTIVE: To back up the names and phone numbers I've manually input into my iPhone.
    THE MONKEY WRENCH: When I plug my iPhone 3g into my Powerbook, under the Info tab is a Contacts section. The Sync Address Book contacts box is checked, and below that box are two choices: All contacts or Selected groups. Computer will not allow me to choose Selected groups, nor can I check off "Put new contacts created on this iPhone into this group", which sounds like, if working properly, would all me to back up my iPhones names and numbers. Please help!
    If you're feeling motivated, you can check out my still unsolved post about trouble I've been having with synching TV shows and let me know if there's one solution to address both issues. Thanks a gazillion.

    Step 1: Configure your iPhone for iCloud, go to Settings > iCloud and toggle the Contacts to Off. It will ask if you want to Keep your contacts that are present in your iPhone or Delete them. Delete only if you have a backup in your Mac or PC. We will be syncing your contacts again from your Mac or PC and upload it to iCloud.
    Step 2: Now, sync contacts with iPhone using your Mac or PC.
    Step 3: Next, go to Settings > iCloud and toggle the Contacts to On. This will Turn on the contacts again. You will get the following screen once you turn on the contacts under iCloud.
    Step 4: You can click on Merge. This will upload your contacts to your iCloud account in a while.
    Step 5: Go to the contacts app to verify if you have only all the contacts synced to your iCloud account.

  • Allow datapicker to only allow Sunday dates to be selected

    Is it possible to limit the users selection to just Sunday dates?
    If so what would be the best approach?
    Thank you

    Hi
    This macro should do what you're asking.
    Private Sub DTPicker1_CloseUp()
        Dim MyDate As Date, MyWeekDay As Integer
        MyDate = DTPicker1.Value
        MyWeekDay = Weekday(MyDate)
        If MyWeekDay <> 1 Then
            MsgBox "You must select a Sunday only"
        Else
            Range("A3") = DTPicker1.Value
            Unload Me
        End If
    End Sub
    A made a sample file with that macro at the link below.
    http://dropcanvas.com/1dfqb
    If that answered your question, please mark the post "Answered"
    Cimjet

  • Select columns in jtable

    Hello,
    I have a JTable component with 4 columns. I only allow single row selection. If I select a row not all columns are selected. The one you clicked on does not have the selection color. Ho can you select all columns with the selection color ?
    regards
    Johan

    Just guessing because I had a hard time wading though all your code. you probably have a custom renderer on that column. Your renderer needs to change the background color if the cell is selected.

  • How do I set only the first row of a DataGrid as the selected row?

    I have a "Go" button on a search form that fetches data into an already data bound grid.  After the data is fetched, I want to make the first row in the Datagrid the selected row, as if the user clicked on it.  If the result set is empty, I don't want the code to crash.  (I only want one row to be able to be selected at a time)
                protected function btnGo_clickHandler(event:MouseEvent):void
                    getSBJsResult.token = baa_data_svc.getSBJs(cmbSrch.text);
                    grdSBJs. //  ?????  What goes here to select the first row?

    This should do it.
    If this post answered your question or helped, please mark it as such.
    if(myDataGrid.dataProvider.length > 0){
      myDataGrid.selectedIndex = 0;

  • If my phone service is disconnected, can I still use the number to iMessage? Under my setting in iMessages it only allows me to select my linked emails and the telephone number is there but grayed out and i can't seletect it !

    If my phone service is disconnected, can I still use the number to iMessage? Under my setting in iMessages it only allows me to select my linked emails and the telephone number is there but grayed out and i can't seletect it ! It wont activate. I just recentely got AT&T.  When I had verizon before and my phone got disconnected it allowed me to still iMessage off my number.

    If your phone service is disconnected, it's not your number any more.
    If you "just got AT&T", how can it be disconnected?

  • Asset selections only allowed in repeat run

    Hi Experts,
    I am was posted Deprication 2009 with 12 periods from Planned posting run.
    When I am doing Deprication 2010 with 1 periods from Planned posting run for perticual period its work in test run u2018 T E S T R U N completed successfully , A document was created u2018, but when I remove the tick from test run system give.
    Error u201CAsset selections only allowed in repeat run Message no. AA734u201D
    Diagnosis
        Processing not possible because of errors in the parameters.
    System Response
        Processing cannot be continued.
    Procedure
        When performing a new posting run or a restart, you cannot limit it to
        the assets you want to be processed. You can only select assets in a
        repeat run. Start the program again with the appropriate parameters.
    Waiting for reply.
    In advance thanks
    Regards,
    Jemes
    Edited by: Jemes on Jun 8, 2010 3:21 PM
    Edited by: Jemes on Jun 8, 2010 3:23 PM

    When you run a planned, restart or unplanned depreciation run you can ony run it  only for all the assets in the real run
    When you have run the planned or unplanned depreciation it create records in the system for all the assets and there are errors then you should run the restart for all the assets.
    The repeat run you use when you have changed 1 or some assets in the old month and wand only to rerun for these assets the depreciation run.
    In a test run you can run it for only some assets but  as no test you have to run it for all the assets (only for the repeat run you can make a selection in the real run)

  • TS1702 My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    Try ejecting your iphone from iTunes and then close iTunes. Now retry. Hope this helps.

  • Scene selection only allows first chapter to play in previews

    In the scene selection screen, iDVD will show each chapter in the movie and allows you to play a short movie clip as a preview. I would think that each chapter would allow you to play a portion of video from that chapter. But instead, iDVD only allows you to play a clip from chapter 1 in all the chapters. That makes no sense. What am I missing here?

    I have same problem. In test mode, clicking on each chapter starts a relevant time in the main movie. But on a burned project only first chapter works, other just loop but when clicked on, nothing happens. Any help around?
    Where can I download IDVD06?

  • Allow edit only user's rows, not someone else's

    Hello
    as you know the option make Form and Report brings a report editable. Is there any way using that option to modify the report to make it non editable?
    OR
    more interesting, that only the user can edit his own row, not the rows of others. That is, there will be different users logging in separately and each willl be adding a row. is there a way one can edit only his row while he has no access to someone elses ?
    thank you
    Al
    Edited by: Alvaroe on 19-Nov-2009 15:29
    Edited by: Alvaroe on 19-Nov-2009 15:34

    Hi,
    maybe there is smarter way to make it, but I used to do it using CASE statement and javascript. I don't have working code, but that's the idea:
    1. In your report you have column with creator name - you use it in your SQL CASE statement like:
    SELECT some_columns, CASE created_by
      WHEN :APP_USER THEN '<a href="#" onclick="goToEditMode('||report_id||')">EDIT</a>'
      ELSE '-'
      END
    "EDIT" FROM your_tableNow if current user has created specified record, edit link appears in EDIT column.
    2. You must add hidden field (P_HIDDEN) to know which row has been selected to edit and javascript function that submits the page:
    <script>
    function goToEditMode(report_id){
    $x('P_HIDDEN').value=report_id;
    doSubmit('EDIT');
    </script>3. Last thing is to create branch that takes you to EDIT page when 'EDIT' request is sent by javascript function. Don't forget to set P_HIDDEN value to edit page in order to know which record is edited.
    Regards,
    Przemek

  • Tab control only allows two page selections

    I am having a hard time understanding why my VI only allows two specific tab clicks every time I run it.
    Should I be using shift registers with the "initializing" Tab Controls on the left of the VI before it enters the loop?
    No matter what I do, it will allow me to change the tab controlled pane two times and then it will not react to anything.
    Once I have reached my maximum alloted, two clicks, then the main Cycle abort button will not react either.
    Kind of stumped...  Any help would be greatly appreciated.
    Attachments:
    FP1.gif ‏252 KB
    BD1.gif ‏201 KB

    WOW,
    you realize that two of your event structures are running in parallel with the while loop- and they will only execute once? One event- one event execution event.  The construct "finishes" done! it won't look for another event.
    Take a look at the shipping examples or the P-C QSM (events) template. 
    Your efforts are not bad, but, show a lack of LabVIEW basics-   Dataflow is a different Paradigm-    (AND REALLY POWERFUL)  but you do need to understand what happens when you use constructs that "break data flow" like locals, globals, and event structures and read the caveats in the LabVIEW help file to get grounded in "best practices"
    CAVEAT:
    I've probably "broken" most of the "best practices" guidelines- Intentionally! but I wanted specific things from LabVIEW that I knew would happen without race conditions.  99.995% of my code does not violate the "best practice" rules.  I write a lot of LabVIEW-  It gives me room in that 0.005% to do "interesting" things. 
    Jeff

  • Paragraph List - Allow more then 1 PAR selection but only once (Unique)?

    Hey all,
    I'm looking at the Studio Handbook in the properties types for the PSL's. I can't figure out which property checkbox I need to check off so it'll allow the user to select more then one PAR, but does NOT allow the user to re-select a PAR that has already been selected.
    thoughts? ideas?

    When you are in the multiline text field, the properties window will show the properties. If you have made the MTL field a paragrph selection (with the check box), you should be able to expand the Paragraph Selection and there is a check box for Single pass - you might also want to check single based on what you have said you need to do.

  • I want the max date but only look at rows with a certain category value.

    I want a way to get the max date but only look at rows with a certain category value - ignoring the other rows.  My detail table contains expenditures including date (col A) and category (col D) the number of rows will increase with expenditures over time.  My summary table will have a cell for each category and display the last expense date for that category using a functionality that I must ask of you, dear community.
    I am using the latest numbers on an iPad (4) with IOS6.
    Secondarily, I would like to add another cell in the summery table with the value (col E) of the last expense for each category.
    Thank you,
    Warren

    ...later...
    With the addition of an auxiliary column to the Main table, a second header row to the Most recent table, and a minor modification to the formula on the second table, the tables can handle a range of dates set by entering the first and last date into A1 abd B1 respectively of the summary table, Most recent.
    Note that the selected range, shown with a green background in the auxiliary column, does not contain any category B expenses. Using LOOKUP, this would result in a repeat of the January 6 expense bering listed in this row. Switching to VLOOKUP, which can be set to require an exact match, allows the result shown—if there are no expenses in a given category, the formula returns "none" (or whatever message you substitute for "none" in the formula in that column).
    Formulas:
    Main::A2: =IF(OR(B<Most recent :: $A$1,B>Most recent :: $B$1),"x"&E,E)
    Fill down to the end of column A.
    This column must be located on the left side of the table (ie. must be column A), but may be hidden.
    Most recent::A2: =IFERROR(VLOOKUP($D,Main :: $A:$D,COLUMN()+1,FALSE),"none")
    "FALSE" will display as "Exact match" in Numbers's formula editor.
    Fill down to the end of the table and right to column C.
    Regards,
    Barry

  • I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but i i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and can't find the solution. This should be a basic thing.

    I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but if i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and i can't find the solution. This should be a basic thing. How frustrating !!

    pedrofromsydney wrote:
    €          55,555.00
    that's the result i get. Still why can't i just type for ex. 29.55 and stay like that on the cell ? Why does it always change to 2955 or 2955.00. ??
    I don't understand this
    It appears you have the cell formatted to Currency, with the default two decimal places.
    What I don't understand, though is how Numbers arrived at a result of fifty five thousand five hundred fifty five on your entering the exact keystrokes in Yvan's post:
    an equals sign, followed by five ones, followed by a forward slash, followed by a 2.
    Here's the result I get:
    Could you do the following:
    Open a NEW Numbers document using the Blank template.
    Drag the Row and Column control (bottom right corner) to reduce the table to two columns and three rows.
    Enter the words "My table" in cell A1.
    Click on cell B2 to select it, then enter the formula 
    =11111/5
    Use only those eight keystrokes; do not include any commas, periods or other characters not shown.
    Click on B2 again to select it.
    Open the inspector and choose the Cell Format button.
    Do not make any changes in the Inspector window.
    Drag the Inspector window to the position shown in my screen shot.
    Take a screen shot that includes the Formula bar, the Table (with cell B2 selected) and the Cell Format Inspector pane (the same screen area as in my screen shot above).
    Post the screen shot in a reply to this post.
    I'm hoping there will be some clues as to what's happening here in the screen shot. Procedure for taking and posting a shot of part of the screen follows.
    Regards,
    Barry
    SCREEN SHOTS (Selected area)
    Place the mouse pointer at the top left corner of the area you want to include.
    Press shift-command-4.
    The mouse pointer will change to a plus sign on a circle.
    Hold down the mouse button and drag to the bottom right corner of the area you wan to capture.
    Release the mouse button.
    The screen shot will be saved to your desktop with the name "Picture 1" (The number will be different if you have taken other screen shots).
    POSTING
    In the Compose frame, place the Insertion point at the location you want the picture to be inserted.
    Click the camera icon above the compose frame to open the Insert Image dialogue.
    Click Choose file to open the Choose dialogue.
    If necessary, navigate to the Desktop and click on the 'by date column header to sort the files by date, most recent at the top.
    Select the most recent picture file.
    Click Choose.
    Wait for the picture's file name to appear beside Choose file.
    Click insert image.
    Done.
    B.

  • How to apply the constraint ONLY to new rows

    Hi, Gurus:
       I have one question as follows:
       We need to migrate a legacy system to a new production server. I am required to add two columns to every table in order to record who updates the row most recently through triggers, and  I should apply not null constraint to the columns . However, since legacy system already has data for every table, and old data does not have value for the 2 new columns. If we apply the constraint, all of existing rows will raise exception. I wonder if there is possibility to apply the constraint ONLY to new rows to come in future.
    Thanks.
    Sam

       We need to migrate a legacy system to a new production server. I am required to add two columns to every table in order to record who updates the row most recently through triggers, and  I should apply not null constraint to the columns .
    The best suggestion I can give you is that you make sure management documents the name of the person that came up with that hair-brained requirement so they can be sufficiently punished in the future for the tremendous waste of human and database resources they caused for which they got virtually NOTHING in return.
    I have seen many systems over the past 25+years that have added columns such as those: CREATED_DATE, CREATED_BY, MODIFIED_DATE, MODIFIED_BY.
    I have yet to see even ONE system where that information is actually useful for any real purpose. Many systems have application/schema users and those users can modify the data. Also, any DBA can modify the data and many of them can connect as the schema owner to do that.
    Many tables also get updated by other applications or bulk load processes and those processes use generic connections that can NOT be tied back to any particular system.
    The net result is that those columns will be populated by user names that are utterly useless for any auditing purposes.
    If a user is allowed to modify a table they are allowed to modify a table. If you want to track that you should implement a proper security strategy using Oracle's AUDIT functionality.
    Cluttering up ALL, or even many, of your tables with such columns is a TERRIBLE idea. Worse is adding triggers that server no other purpose but capture useless infomation but, because they are PL/SQL cause performance impacts just aggravates the total impact.
    It is certainly appropriate to be concerned about the security and auditability of your important data. But adding columns and triggers such as those proposed is NOT the proper solution to achieve that security.
    Before your organization makes such an idiotic decision you should propose that the same steps be taken before adding that functionality that you should take before the addition of ANY MAJOR structural or application changes:
    1. document the actual requirement
    2. document and justify the business reasons for that requirement
    3. perform testing that shows the impact of that requirement on the production system
    4. determine the resource cost (people, storage, etc) of implementing that requirement
    5. demonstrate how that information will actually be used EFFECTIVELY for some business purpose
    As regards items #1 and #2 above the requirement should be stated in terms of the PROBLEM to be solved, not some preconceived notion of the solution that should be used.
    Your org should also talk to other orgs or other depts in your same org that have used your proposed solution and find out how useful it has been for them. If you do this research you will likely find that it hasn't met their needs at all.
    And in your own org there are likely some applications with tables that already have such columns. Has anyone there EVER used those columns and found them invaluable for identifying and resolving any actual problem?
    If you can't use them and their data for some important process why add them to begin with?
    IMHO it is a total waste of time and resources to add such columns to ALL of your tables. Any such approach to auditing or security should, at most, be limited to those tables with key data that needs to be protected and only then when you cannot implement the proper 'best practices' auditing.
    A migration is difficult enough without adding useless additional requirements like those. You have FAR more important things you can do with the resources you have available:
    1. Capture ALL DDL for the existing system into a version control system
    2. Train your developers on using the version control system
    3. Determining the proper configuration of the new server and system. It is almost a CERTAINTY that settings will get changed and performance will suffer even though you don't think you have changed anything at all.
    4. Validating that the data has been migrated successfully. That can involve extensive querying and comparison to make sure data has not been altered during the migration. The process of validating a SINGLE TABLE is more difficult if the table structures are not the same. And they won't be if you add two columns to every table; every single query you do will have to specify the columns by name in order to EXCLUDE your two new columns.
    5. Validating the performance of the app on the new system. There WILL BE problems where things don't work like they used to. You need to find those problems and fix them
    6. Capturing the proper statistics after the data has been migrated and all of the indexes have been rebuilt.
    7. Capturing the new execution plans to use a a baseline for when things go wrong in the future.
    If it is worth doing it is worth doing right.

Maybe you are looking for

  • Updated to 10.5.6

    updated to 10.5.6 and now motion 2.1 wont start up. I get a could be ozone plugin. yet it wont even boot up without it. any suggestions? thanks getting real sick and **** tired of these updates. never know what to expect anymore. anyway. any help wou

  • Cluster table and views

    1. can i use cluster tables in my report 2. what are the views in xd01,xk01 and mm01

  • Pack.sh - Fatal Error

    Hi to all, i try to build a wls Cluster with two pysical machines. i installed and configured wls and fmwhome on server 1, erverything running fine (soa_server1 and bam_server1). Now i have to build the wls Cluster. for that i installed the same wls

  • What do I convert AVI's to so I can edit them in final cut pro?

    Hi, I made a house walkthru in autodesk REVIT, and the only export option was uncompressed AVI. I cannot play that format on my mac, nor can I edit that footage in final cut pro. Is there a way to convert the AVI movie to quicktime or another format

  • Regarding the Educational versions

    Dear Sir/Madam, As we do like to purchase your product Adobe Master Suite, i had went through your prices of them which were quite high. As we are an Educational Academy in Sri Lanka, please do let us know whether it is possible to have Educational v