Only focus on items in JTable wich are editable

Hi,
I have a jtable with custom renderers and sometimes editors. When I tab through the table I only want it to tab from editable field to editable field thus skip the normal fields. Does anyone know how to do this?
Thanks is advance,
Hugo

This example shows some things you can do with InputMaps and ActionMaps:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableActions extends JFrame
    public TableActions()
        JTable table = new JTable(15, 5)
            public boolean isCellEditable(int row, int column)
              return column % 2 == 0;
//              return false;
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
        InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        //  Have the enter key work the same as the tab key
        KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
        KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
        im.put(enter, im.get(tab));
        //  Disable the right arrow key
        KeyStroke right = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
        im.put(right, "none");
        //  Override the default tab behaviour
        //  Tab to the next editable cell. When no editable cells goto next cell.
        final Action oldTabAction = table.getActionMap().get(im.get(tab));
        Action tabAction = new AbstractAction()
            public void actionPerformed(ActionEvent e)
                oldTabAction.actionPerformed( e );
                JTable table = (JTable)e.getSource();
                int rowCount = table.getRowCount();
                int columnCount = table.getColumnCount();
                int row = table.getSelectedRow();
                int column = table.getSelectedColumn();
                while (! table.isCellEditable(row, column) )
                    column += 1;
                    if (column == columnCount)
                        column = 0;
                        row +=1;
                    if (row == rowCount)
                        row = 0;
                    //  Back to where we started, get out.
                    if (row == table.getSelectedRow()
                    &&  column == table.getSelectedColumn())
                        break;
                table.changeSelection(row, column, false, false);
        table.getActionMap().put(im.get(tab), tabAction);
    public static void main(String[] args)
        TableActions frame = new TableActions();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.pack();
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
}

Similar Messages

  • WebPart is raising the following error "Invalid data has been used to update the list item.The field you are trying to update may be read only"

    I have created a farm solution and then i deploy it to SharePoint server, the code looks as follow, and i use it to update a page info values (as the current page values represents old info):-
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
    // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
    // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
    // for production. Because the SecurityPermission attribute bypasses the security check for callers of
    // your constructor, it's not recommended for production purposes.
    // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
    public VisualWebPart1()
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["Pages"];
    web.AllowUnsafeUpdates = true;
    foreach (SPListItem items in list.Items)
    items["Author"] = "SharePoint";
    items["Created"] = "01/08/2014 01:44 PM";
    items.Update();
    list.Update();
    web.AllowUnsafeUpdates = false;
    protected void Page_Load(object sender, EventArgs e)
    but when i try adding this web part to a page i got the following error:-
    Invalid data has been used to update the list item.The field you are trying to update may be read only
    so can anyone advice?

    i only changed lines bitween 
    web.AllowUnsafeUpdates = true;
    and
    web.AllowUnsafeUpdates = false;
    and other parts of code remains without change
    so it will updates all pages in current web
    yaşamak bir eylemdir

  • In my library, under the Artist column only...items are not listed in alpha order.  How can I get that to happen?

    In my library, under the Artist column only...items are not listed in alpha order.  How can I get that to happen?

    Same deal as your other thread but with Artist/Sort Artist:
    https://discussions.apple.com/message/25561674#25561674
    For more info. on how iTunes organizes things see Grouping tracks into albums.
    tt2

  • TS3999 The calendar in Outlook (and icloud) doesn't print all the events.  Only a few items are printed.

    I joined icloud and now have 3 calendars in Outlook: Calendar in iCloud, Calendar (2) in iCloud and Local Calendar in iCloud.  When I try and print the calendar only a few items print.  Most of the items/events in the calendar on the computer are not on the printed calendar.  Has anyone else had that problem?  How do I get in touch with an iCloud support person? 

    Thanks Carolyn for the swift reply.
    Tried on both but unfortunately didn't work for me.
    I will create a new calendar called "Birthdays1" and will enter all birthdays again to see if that works.
    Problem seems to be only with the Birthday calendar so might be corrupted over time?
    Find it strange though that the Birthday calendar does appear correct and complete on my iCloud account online.
    Rgds
    Bo

  • There are only 00000001 serviceable items Received

    Hi Friends,
                   Kindly explain me the process of replacement and scrapping in Customer service module in detail.
    I have created the service notification>repair order>return delivery and when selecting the replacement and
    scrapping check boxes in VA02 (repair order) >Sale tab>Repairs icon I am facing the error message "There
    are only 00000001 serviceable items Received".
    Kindly suggest me the best
    Thanks and regards,
    Swamy H P

    Hi,
    Process
    Notification >> Create repair order from notification (RAS) >> Return delivery >> usage decision(Reapir/scrap/replace)
    In repair order initially 2 line item
    10000 - IRRS (Repair resource)
    10100 - IRRE (for return)
    Once you take return the stock will come under sales order
    Then go to order >> Repairs
    Then click on INSERT ROW and maintain qty 1, tick mark to REPLACEMENT and mention same serviceable item
    Then system will generate item 10200 - IRAT (Repair exchange)
    Then again click on INSERT ROW and maintain qty 1, tick mark to SCRAP and mention same serviceable item
    Then system will generate item 1300 - IRVE (Scrap)
    SAVE
    Now deliver replacement item through VL01N
    Trasfer sales order stock to scrap
    kapil

  • My keyboard appears to be in French only on Firefox. IE and Word are okay. The apostrophe shows as è and the bar shows as à etc.

    My keyboard appears to be in French only on Firefox. IE and Word are okay. The apostrophe shows as è and the bar shows as à etc.
    Last week I had a problem with the special characters but that is resolved since I closed and reopened but I havenèt tried that yet but will as well. Very frustrating though - why is this happeningÉ

    See:
    * http://windows.microsoft.com/en-US/windows7/The-Language-bar-overview The Language bar (overview)
    It is possible that you have switched the keyboard layout by accident.
    * Make sure that you have the Language bar visible on the Windows Taskbar.
    * You can do that via the right-click context menu of the Taskbar: Toolbars > Language Bar.
    * Check the keyboard language (keyboard layout) setting for the application that has focus via the icon on the Language bar.
    * You need to do that while Firefox has focus because Windows remembers the keyboard layout setting per application.
    * The default keys to rotate the layout is a combination (Ctrl+Shift or Alt+Shift) that can easily be used in Firefox to activate a menu item.
    * To avoid an unintentional switch assign a specific key sequence (Alt/Ctrl+Shift+number) to select keyboard layouts and remove the key combination to rotate layouts (Alt+Shift or Ctr+Shift)
    * Control Panel > Regional and Language Options > Keyboards and Languages > Change keyboards > Advanced key settings > Change key sequence

  • When using private browsing to view image results in Safari 5.1.3, only the first two rows of results are visible, the following four or so rows display greyed out place holders, and the safe search button is inoperable. Suggestions?

    When using private browsing to view image results in Safari 5.1.3, only the first two rows of results are visible, the following four or so rows display greyed out place holders, the remainder of the results page is blank, and the safe search button is inoperable. When I turn off private browsing and refresh the page, everything works again.
    Anyone else having this problem?

    I have got the same behaviour after the last Safari Update to 5.1.3. It seems that Safari now handles some scripts in a new way. If you debug the Google Website, you will see, that there is some Javascript Error, that seems to prevent to write into local cache. After some searching I wasn't able to finde a solution for this problem, other then disabling Javascript while private browsing to prevent the script loading. You then are able to use Google with the old layout. The option to disable JavaScript can be found in the Menu "Developer", wich has to be enabled in Safari in the options first.
    In my opinion this is a bug that is now occuring, because Apple changed something in private browsing and that has to be fixed by Google now, to run again. Or we will have to wait for 5.1.4, as you can read online Apple will change and bugfix the javascript engine in that version, perhaps this fixes the problem as well. I hope so!
    If anyone is in the developer program perhaps you could test this with the beta of 5.1.4 and tell us if it works.

  • Load FI data only for open items

    Hi all
    I want to load FI data only for open items.
    We started off with FI_GL_4 which has STATUSPS(status of FI line item)based on which we have written a start routine to filter out the closed items.
    But for other FI-GL datasources we dont have STATUSPS field.
    Then can we load data directly without applying any restriction on it as we dont have STATUSPS field in it?
    Or is there an other way to find all open items ?
    Please helpout.
    Awaiting replies.
    Harika.

    Hi Harikag,
    when you are loading delta data in 0FI_GL_4, it is NOT the right approach to load only the open items.
    Say for example, you have loaded a record with open status.
    If the status of the record gets changed to 'Closed' in SAP, then this will not flow to BW, because of the filter that you are trying to apply in the data load.
    So the item will continue to remain open in BW, though it is closed in R3.
    hence it is highly recommended to do this filtering at report level.
    Otherwise, you are looking at full load option by dropping data everyday, which will have performance issues in loading.
    Thanks,
    Krishnan

  • Credit check only open billing item

    Dear Folks,
    Is it possible to do a creditcheck in the sales order on the basis of only open billing items and not at open sales order?
    Thank you very much.

    If I have correctly under stood your question, then the answer is <b>NO. It cannot be done.</b> All the three update groups ( in case of Automatic Credit control) consider both Open Items and Open sales order values. Even in the Simple credit limit check, the Credit value is calculated basd on Open Items and the Current Sales Order value.
    <b>Simple credit limit check</b>
    A credit limit check can be carried out when sales documents are created or changed. The check is carried out within one credit control area. When changing a document, the check is repeated if changes regarding quantity or value are made. A credit control area consists of one or more company codes. A sales document belongs to one credit control area depending on the allocation of the sales organization to a company code. The SAP System checks the credit limit which was granted to the customer in this credit control area. The credit control areas and the credit limit of a customer are defined in financial accounting and entered in the customer master record. During the check, the SAP System totals the receivables, the open items from special G/L transactions and the net value of the sales order for every item of a sales document. The open items take into account obligations bound by contract which are not recorded for accounting purposes but which involve expenses through diverse business transactions. The total is compared with the credit limit. If the limit is exceeded, the system responds in the way defined by you in the configuration menu.
    Hence, I think this is not possible in std sap, but if anybody knows a workaround, then I will be certainly glad to know.
    Thanks

  • Preparing Balance sheet by using profit centers only for BS Items

    Dear Experts,
    could you please help me out regarding the following issue.
    business area wise we can get the balance sheet but i want to know is there any possibility to get the BS by using profit centers only for BS Items or can we assign biasness area as well as profit center in a single screen.

    Hi!
    You can use following report :
    S_ALR_87013336 (Report for Balance sheet at Profit Center and Group Level).
    Hope this will help.
    Thanks & Regards,
    Taral Patel

  • Items in the invoice are being duplicated...

    Hello,
    We have invoice and that invoice has 6 items with diff prises. but 2 of the items with are having same information and they have been duplicated and same item is being charged twise... does any1 have any idea?
    Please let me know
    Regards,
    lata.

    Hi Latha,
    Please check the Sales order and confirm that the items are intact i.e.,there are only 6 line items and with different prices,check the delivery and if everything is same and different only in invoice,check the copy controls.
    Hope this helps you certain extent.
    SriRam

  • OE:Item Validation Organization - view only your Org Items in SO Item LOV

    HI All,
    I am trying to set a profile so that I see only the items in my Organization in the Sales Order Item LOV in Order Management when I create a sales order.
    Appreciate your input to achieve this.
    Thanks,
    Jo.

    Thanks for this information...
    We can specify only one Item validation org for one operating unit (OU) in Order management as well as in Purchasing.
    Say we have total 5 orgs in OU, one is ITM item master and others are ORG1, ORG2, ORG3 and ORG4. Suppose ORG1 is an Item validation org...
    Now if Oracle is going to validate attribute values against ORG1 only then problem may come... in case few attributes are controlled at organization level then same attribute can have different values in different orgs say the attributes are Purchasable and Customer order enables..
    If the item is not purchasable and not Customer Order enabled in ORG1 (Item validation Org).. then do you mean it can't be sold or purchased in that OU??... I don't think so...
    So I want to know what is the significance of having Item Validation Organization...ac
    Thanks
    Devendra Gulve
    http://functionalguy.blogspot.com
    Edited by: Deven.G. on Sep 2, 2010 12:04 PM

  • Authorization scheme for display/read only conditions on item level

    Hi All,
    I have question. I want to use an authorization scheme to manage if users with a certain role have the permission to either update an item or have the persmission to only see the item or that they don't have permission to see it at all.
    So, the input for the scheme would be: 1. user role 2. the current page 3. the current item.
    The output would be: 0 (update) 1 (read only) 2 (not displayed).
    I think I can manage that.
    And I can attach this schema to the items.
    So far so good.
    But how can I make it so that the 0,1 and the 2 will actually do what they need to do?
    I have been thinking about making a function like GET_AUTHORISATON(ROLE,PAGE,ITEM) output: 0,1,2 but I still can't figure out how to connect this with the functionality I want to achieve.
    Can somebody give me a hint?
    Andre

    Thanks Hari,
    Thanks, it works, almost, but what if items are mandatory on a page, but not always mandatory?
    If a user has a certain role, some fields are manadatory, otherwise not.
    Again, a function would do the trick as far as the input and output information
    something like IS_MANDATORY(USER_ROLE, CURRENT_PAGE, CURRENT_ITEM) but how can I make it work?
    I guess a PL/SQL validation like:
    IF IS_MANDATORY(USER_ROLE, CURRENT_PAGE, CURRENT_ITEM) THEN ITEM IS NOT NULL
    END IF;
    Andre
    PS: personally I think item level security is not something you wish to implement in your system. I prefer different screens for different roles.
    Far more straightforeward. Easy for maintenance. When something disfunctions, it's far more easy to pinpoint the location of the cause.

  • Dreamweaver cc 2014 : why do I get error 404 on menu list item on only one list item?

    I have a list on my menu that only the last item 2009-2014 will not function. All other links in the list work. coding is the same on all items but having been trying for days and unable to get 2009-2014 to work no matter how many times I create and recreate it.
    url: www.strangersrestbc.com  (thought I had posted this originally under DW CC 2014 but can't find my original discussion)
    thanks,
    howard

    Looks like you either...
    1. Haven't uploaded the re4.jpg image
    2. Uploaded it to the wrong location (the link says it should be in your site root)
    3. Uploaded the image with the wrong name (RE4.jpg and re4.jpg are the same on your local system, but on a server they're separate files)
    Actually, #3 is true, I found the image as RE4.jpg, but the link is to re4.jpg
    To avoid this in the future, make sure your files all use lowercase, alpha-numeric names. Avoid using spaces (use hyphens and underscores instead) and avoid special characters like #&$ all together.

  • Disable focus on cell after JTable is disabled for editing

    Hi!
    I have, (like so many others ) problems with JTable.
    I have a table, wich in default is non-editable. I can add rows using the "new"-button, and enter values with inputdialogs.
    I can also select rows in the table( still without editing) and delete the selected rows with the "delete"-button.
    BUT!
    I have a "edit"-button(togglebutton). When this is pressed, user is allowed to edit cells in the table by double-clicking on them. If the user press the edit-button for the second time while the marker is in the active cell, the table once again becomes non-editable, except the active cell.
    if the user, before clicking the editbutton for the second time clicks one time on an other cell, it works out great, and non of the cells are editable...
    If anyone can help me, I'll be very greatfull and my boss very happy.
    moitor

    stop the edition of the JTable before setting your JTable as non editable
    TableCellEditor editor = table.getCellEditor();
    if (editor != null)
        editor.stopCellEditing();

Maybe you are looking for

  • Mic wont work.

    I cant get my microphone to work, it worked fine last week. I tried a different mic and it still wont work. So I think its my laptop. I reinstalled my sound card and made sure it wasn't muted.

  • How many types of projects exist in sap bw

    i heard that there are two types of projects 1.implementation project 2.support project and what about up gradation project, migration project, and i want to know what all the projects exists and there processes.. if not possible please provide the l

  • Glitch with InDesign CS5s Live/Static Caption...

    I've been following some of the forums re: problems with generating live/static captions, but none have solved this problem. I'm laying out thumbnails to generate caption info from the EXIF data. All the EXIF data can be seen when in Bridge but only

  • Activesync issues with large contact notes field

    I'm running into an issue where changes made at the end of a large note in a contact do not get synced, while changes at the beginning do. Can anyone else confirm? Is this an activesync or apple implementation issue? I ran into something similar on t

  • Why does my ipad keep timing out

    My ipad keeps timing out saying server timed out every time I search the web or try to check my email