Jtable keep the selected cells' background

hi,
I want to change the background color of the selected cells.
after selection, I may do another selection,but I want to keep the previous selected cells' background color.
any help will be appreciated!
thanks!
zhangv

Did you try using Ctrl + Mouse Click ?
Remember you need to set following property before you try the above solution:
tableObj.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );

Similar Messages

  • How to change a selected cell background color in JTable?

    Hi all,
    I am trying to change the background color of a selected cell by clicking on that particular cell. DefaultTableCellRenderer class provides setBackground(Color c) to change the background color of unselected cells. Is there a way to change a selected cell background color?
    Thank you,
    Arthur

    Write your own renderer (eg. extending DefaultTableRenderer) and put in getTableCellRendererComponent method something like this:
    if( isSelected && hasFocus )
        setBackground( Color.RED );
        setForeground( Color.GREEN );
    }

  • How to get the selected cell in a Matrix.

    Hi all,
    Does any one know how to get the selected cell in a Matrix. Please help to answer. Thanks in advance.
    Regards,
    Thanh Tran

    Hi,
    You can get the value of every cell  using UI API but using datasources is a better aproach.
    Using UI API you need to know the event you want to catch. Example: Catching click event in itemcode column and getting the value (C#):Ki
          if ((pVal.EventType == BoEventTypes.et_CLICK) &&  //CLICK EVENT
              (pVal.ItemUID == "38")  &&                                       //MATRIX-> ITEM 38
              (pVal.ColUID == "1") &&                                           //ITEMCODE COLUMN
              (!pVal.InnerEvent) &&                                
              (!pVal.BeforeAction))
                    Form form = null;
                    try
                        form = kernel.Application.Forms.Item(pVal.FormUID);
                        form.Freeze(true);
                        Matrix mtx = (form.Items.Item(pVal.ItemUID).Specific as Matrix);  //MATRIX OBJECT
                        string itemCode = (mtx.Columns.Item("1").Cells.Item(pVal.Row).Specific as EditText).Value.Trim();  //itemcode = VALUE OF CELL. COLUMN "1": ITEMCODE COLUMN. CURRENT ROW: pVal.Row
                    catch (Exception ex)
                        kernel.Application.MessageBox("Error " + ex.Message, 0, "", "", "");
                    finally
                         if (form != null)
                            form.Freeze(false);
    Kind regards,
    Nauzet Díaz

  • "The selected cells are read-only" error on Custom Field when trying to insert in Datasheet mode

    I have a custom field that works completely fine. Yesterday our QA team found out that when trying to insert in Datasheet format, the error "The selected cells are read-only" was thrown. Any ideas? I tried passing the following property to my fldtypes_field.xml file:
        <Field Name="ReadOnly">FALSE</Field>
    No luck.Victor Palma

    Unfortunately it did not work. I also developed the code and access the field and checked its property called "ReadOnlyField"  which is already set to false.
    Below is the xml that i am using. Can you please share the xml that you had used?
    <?xml version="1.0" encoding="utf-8"?>
    <FieldTypes>
      <FieldType>
        <Field Name="TypeName">MyCustomField</Field>
        <Field Name="ParentType">Text</Field>
        <Field Name="TypeDisplayName"> My Custom Field</Field>
        <Field Name="TypeShortDescription"> My Custom Field</Field>
        <Field Name="AllowBaseTypeRendering">True</Field>
        <Field Name="ReadOnlyField">False</Field>
        <Field Name="UserCreatable">TRUE</Field>
        <Field Name="ShowInListCreate">TRUE</Field>
        <Field Name="ShowInSurveyCreate">TRUE</Field>
        <Field Name="ShowInDocumentLibraryCreate">TRUE</Field>
        <Field Name="ShowInColumnTemplateCreate">TRUE</Field>
        <Field Name="FieldTypeClass">My Assembly Information goes here</Field>
      </FieldType>
    </FieldTypes>

  • How to get the dimensions of the selected cell in java client

    hi,
    I am able to retrieve the value of a particular cell using the data access package.i want to know how can i get the measure and dimension of a particular cell in java client.is it possible to get the row and edge of the selected cell?please help me in this.
    thanks and regards
    S.Sharanya

    hi,
    I am able to get the value like 'RM00' of the dimension by using the method,
    m_activeView.getModel().getDataAccess().getValueQDR(1,1,1).getDimMember(m_activeView.getModel().getDataAccess().getValueQDR(1,1,1).getDimensions().nextElement().toString()));
    but this give all the values of the each dimension for each cell of the crosstab.but i want the values of dimension which is selected.i am able to get the selected dimension usind qdr method,for which i am getting the output like
    MDM!MEASUREDIMENSION(MDM!D_DEMO1.RESIDUAL_DIM 'RM00', MDM!MEASUREDIMENSION 'MDM!M_DEMO1.PD_BR_RMT_LDRUN_CUBE.PBRL_SIM', MDM!D_DEMO1.PRODUCT_DIM 'G001', MDM!D_DEMO1.LOADRUN_DIM '3', MDM!D_DEMO1.BRANCH_DIM 'HO01')
    i want to know the method so that i can get only values ,like RM00,G001,3,H001.is there any method,so that i can get all these value alone.pls help me.i am not able to proceed without this.
    thanks
    s.sharanya

  • AdvancedDataGrid: I cannot relate the selected cells to the dataprovider

    If you look at this
    http://livedocs.adobe.com/flex/3/langref/mx/controls/AdvancedDataGrid.html#selectedCells
    The selectedCells work fine if you have ungrouped data but when items are grouped the row index does not realte to the flat dataprovider but the grouped rows in the ADG display. This is annoying as I cannot relate the selected cells to the dataprovider.
    Any ideas how to get around this?

    Ok so if i write some text and all the words are of different sizes and i have to resize it using the transform tool, i cannot resize it unto the size i want. e.g.. i wrote this text "The Big Bold Sale" all the words are of different sizes and are grouped together, so when i resize it using transform tool all these words are resized differently "The big" becomes big, "bold" becomes little smaller and "sale" is not resized.. the image is attached.

  • TableView: keep the selected page

    I use a htmlb:tableView with 50 - 100 entries.
    The visible row size is 20, so I have multiple pages.
    Is there a way to keep the selected page after a round trip.
    At the moment, the first page is shown after each round trip, no matter which page was selected before.

    Hi Daniel,
    I have the same problem and I wish I had a solution like displayed upon :-). Here some hacking.
    First in DO_HANDLE_EVENT method of controller:
    * keep selected page of table view
      DATA: lcltvevt TYPE REF TO cl_htmlb_event_tableview.
    * first get the correct event
      IF htmlb_event->if_htmlb_data~event_name = 'tableView'.
        lcltvevt ?= htmlb_event.
        IF lcltvevt->id = 'MY_CDAG_TABLE' "your tableView id
          AND lcltvevt->event_type = 'navigate'
          AND lcltvevt->navigationmode = 'BYPAGE'.
    *     navigate pageDown, pageUp, top, bottom
          CASE lcltvevt->navigationtype.
            WHEN 'Index'.
    *       sorry I have no idea for index
            WHEN 'pageDown'.
    *         hold data in model instance       
              lcl_mo->cdag_add_info-firstvisrow =
              lcltvevt->firstvisiblerow +
              lcltvevt->visiblerowcount.
            WHEN 'pageUp'.
              lcl_mo->cdag_add_info-firstvisrow =
              lcltvevt->firstvisiblerow -
              lcltvevt->visiblerowcount.
            WHEN 'top'.
              lcl_mo->cdag_add_info-firstvisrow = 1.
            WHEN 'bottom'.
              lcl_mo->cdag_add_info-firstvisrow =
              ( lcltvevt->rowcount DIV
              lcltvevt->visiblerowcount )
              * lcltvevt->visiblerowcount + 1.
          ENDCASE.
        ENDIF.
      ENDIF.
    secondary in the view:
              <htmlb:tableView id              = "MY_CDAG_TABLE"
                               visibleRowCount = "12"
                               fillUpEmptyRows = "false"
                               allRowsEditable = "X"
                               table           = "//MODEL/CDAG"
                               headerVisible   = "FALSE"
                               iterator        = "<%= it_cdag %>"
                               visibleFirstRow = "<%=model->cdag_add_info-firstvisrow%>" />
    If you want to get the index, try this
    * check for selection mode (for later using internal)
      CALL METHOD request->get_form_field
        EXPORTING
          name  = `htmlbevt_par1`
        RECEIVING
          value = l_name_of_event.
    * l_name_of_event is something like "Index,1,12,20,P" on index selection.

  • Changing the background color of the row of the selected cell in table view

    How can I change the background color of the table row when user clicks on table cell in table view?
    Edited by: a_brar on May 5, 2012 11:12 PM

    You could apply the following css style (by defining a custom stylsheet with the following lines and loading it into your app).
    The last color sets the background color of the selected row while the table-view has focus (in this case to orange).
    .table-view:focused .table-row-cell:filled:focused:selected {
        -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, orange;
    }There are quite a lot of subtleties in the css styling for the tableview (e.g. different colors for the selected row when the control has focus vs when it doesn't or when the user hovers over a selected row in an unfocussed tableview), which you may want to cater for when chaning the background color of the selected row in a table view. There is also alternate styling for when the tableview is in row selection vs cell selection mode. So you may want to look at customizing further based on the css styles in caspian.css in sdk/rt/lib/jfxrt.jar if you can understand the complex css there.

  • How do I scroll a JTable as the selection cursor moves out-of-view?

    If a row is selected in a JTable, and the user navigates up and down using arrow keys, as the selection moves out of view, the table automatically scrolls. In my app, I am programmatically selecting rows, but if the selection is out of view, the table does not scroll. does anyone know how to achieve this? I know I could examine the position of the selected row etc. and scroll the view myself, but this seems clunky. Ideally, I would fire off KeyEvents to get the behaviour for free, but I can't see where to fire them to

    I know I could examine the position of the selected row etc. and scroll the view myselfWhy? Thats what the methods where designed for (assuming you are talking about the scrollRectToVisible(...) method).
    Ideally, I would fire off KeyEvents to get the behaviour for free,That seems clunky to me.
    When you use KeyEvents its a cause / effect relationship. That is first you use a KeyEvent to change selection. Then then if the table is at the bottom it scroll one row. So in you program if you on on row 5 and you want to select row 30, you would need to invoke 25 KeyEvents. Seems pointless to me unless you have special logice that processes every row as it gets selected.
    If you want to persue this route then you can just invoke the default actions for the up/ down/ left/ right keys. This posting should give you an idea of how to do this:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=657819

  • How to keep the selection as the old when I select one and click the submit

    maybe it is a HTML problem,but I still ask for help here!
    When I select one option in the form's element-select and submit it ,I want to keep the JSP page as old, but I can't .I also use cookie and bean.The problem is still being.

    store the parameter names and their corresponding values in a variable, say Hashtable. After you do the submit, you can retrieve the values from the hashtable.
    example:
    if you have these parameter names:
    "name", "age"
    then you can do:
    Hashtable h = new Hashtable();
    h.put("name", request.getParameter("name"));
    h.put("age", request.getParameter("age"));Have this hashtable available in your response jsp so you can retrive the old data.

  • How to keep the select arrow on the same button when returning to the menue after finished feature?

    Hello,
    just after my primary question is answered and I corrected my buttons there's another one which I cannot answer myself:
    I'm putting together a DVD with menues which contain a lot of options/buttons. People who watched the DVD wanted that the select/highlight arrow stays/returns to the button they selected prior. That's because there are so many buttons/options that some people might not remember which feature they just watched. So this means if people select the "Vacation 2008" button/feature the select/highlight arrow should be on the same button after the feature is finished and it returns to the menue.
    Since I haven't seen any functions/options for this: Is it possible to do or isn't it or does it happen just naturally?
    Hope this isn't too confusing :-)
    Help is appreciated!
    Thank you,
    Chris...

    ChrisHei wrote:
    Where would I select "Last Menu" for this to happen? In the properties for the button or for the timeline? And where exactly: "overwrite" or "remote menu" selection?
    Not in any override. Don't set any overrides unless you understand exactly how they work, or they will royally mess up your disc navigation.
    Normally, you select "Return to Last Menu" for an end action of the object (timeline, slideshow, playlist, etc.) that is playing. You can also set the Menu Remote property for the timeline/slideshow to "Return to Last Menu".

  • Keyboard not keeping the selected type UK Extended

    I have followed the instructions from K Hsu but the keyboard never changes to UK Extended.
    I am running Win 8.1 Pro in a virtual machine (VirtualBox) trialing it for deployment.
    The Host is a Windows 7 Ultimate and other Win 7 VMs all work fine and use the UK Extended keyboard layout. In the Win 8.1 VM the original installation account selected the UK extended keyboard which works fine. However a second account was setup with a
    different sign in account to examine how that would affect the operation. This VM account cannot change the keyboard layout from US English to UK Extended. The instructions were followed closely and repeated numerous times but the change never happened. It
    is preventing the easy use of mail because the @ symbol comes up only if shift 2 is pressed instead of shift ' which causes a " to appear. 
    Advice please.

    Hi,
    Based on my test, we can change the keyboard layout from US English to UK Extended.
    But we need to add the UK language when you use your new account.
    I would like to confirm if you added the UK language when you used other account to login your Windows 8.1 VM.
    Please check the following location:
    Regards,
    Kelvin hsu
    TechNet Community Support

  • How to get row of the selected cell  in ALV  while implementing OVS

    Dear Folks,
                    I am implementing OVS search help in ALV.When i click on cell, i can see the search help in  cell and now i can identify the colomn of the cell but i can't identify the row of the cell.Can any one tell me how to identify row of the cell in this case.
    Nirad.

    Thnx for the answer nithya.I have solved problem my self.
    DATA: elem_ovs TYPE REF TO if_wd_context_element,
            ls_data TYPE REF TO data,
            ls_index type string.
      FIELD-SYMBOLS : <ovs_data> TYPE data.
      elem_ovs = ovs_callback_object->context_element.
      ls_data = elem_ovs->get_static_attributes_ref( ).
      ls_index = elem_ovs->GET_INDEX( ).
    and this is the solution.

  • A problem to get the value of a selected cell

    Hi all,
    I am trying to get the value of a cell in JTable. The problem that I have is ListSelectionListener only listens if the selection changes(valueChanged method).
    It means that if I select apple then rum, only rowSelectionModel is triggered, which means I do not get the index of the column from selectionModel of ColumnModel.
    apple orange plum
    rum sky blue
    This is a piece of code from JTable tutorial that I modified by adding
    selRow and selCol variables to keep track of the location so that I can get the value of the selected cell.
    Thank you.
    if (ALLOW_ROW_SELECTION) { // true by default
    ListSelectionModel rowSM = table.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
    if (lsm.isSelectionEmpty()) {
    System.out.println("No rows are selected.");
    } else {
    int selectedRow = lsm.getMinSelectionIndex();
    selRow = selectedRow;
    System.out.println("Row " + selectedRow + " is now selected.");
    else {
    table.setRowSelectionAllowed(false);
    if (ALLOW_COLUMN_SELECTION) { // false by default
    if (ALLOW_ROW_SELECTION) {
    table.setCellSelectionEnabled(true);
    table.setColumnSelectionAllowed(true);
    ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
    colSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    //Ignore extra messages.
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
    if (lsm.isSelectionEmpty()) {
    System.out.println("No columns are selected.");
    } else {
    int selectedCol = lsm.getMinSelectionIndex();
    selCol = selectedCol;
    System.out.println("Column " + selCol + " is now selected.");
    System.out.println("Row " + selRow + " is now selected.");
    javax.swing.table.TableModel model = table.getModel();
    // I get the value here
    System.out.println("Value: "+model.getValueAt(selRow,selCol));
    }

    maybe you can try with :
    table.getSelectedColumn()
    table.getSelectedRow()
    :)

  • JTable selected cell highlight

    Hi,
    I want to reproduce Excel behaviour in a JTable :
    highlight the cell on which user has clicked once
    show the caret when the user has double-cliked on it.
    The second behaviour looks like being built-in the JTable
    But when the user clicks once on the cell not visual effect appears
    to reflect the click event.
    I would like to have the selected cell "border" painted in another color.
    Would you have a hint for that ?
    thanks

    Thanks you the hint Razor_Blade.
    could you elaborate a bit more please.
    I don't feel like getting deep into rendering stuff now,
    and was expecting a simple solution.
    But if there's no, don't bother.
    It will take the time that it needs but I'll find out.
    thx.

Maybe you are looking for

  • Secure Zone Customer Activity Tracking

    I'm new to Business Catalyst, so this may be obvious to some of you, but I have a question about tracking customer activity on my Business Catalyst site. I can track logins into Secure Zones, but only whether/not the customer has logged into the site

  • Contacts entered on iPhone 4S does not sync to iCloud

    Using iCloud with an iPhone 4S (version 5.0.1). When I enter a contact on the iPhone, it will NOT sync to iCloud.  However, when I enter a contact on www.icloud.com, it WILL sync to the iPhone.  And yes, I am entering the contacts in the correct grou

  • Idoc for EDI

    Hi I want to know how do we serch for standard IDocs associated with some EDI. I want to search for Idoc associated with EDI 276 & EDI 277. How can I search it & can some body tell me the idoc  name itself if also possible with procedure

  • Internal table with header line and work area.

    data:itab like LIKE bapimepoheader. DATA : BEGIN OF it_po_items OCCURS 0.         INCLUDE STRUCTURE bapimepoitem. DATA : END OF it_po_items. DATA:it_input         TYPE STANDARD TABLE OF typ_input,       wa_input         TYPE typ_input, LOOP AT it_inp

  • Wrong data values displayed for YTD in reports

    Hi, In my reports when i try to select measures as YTD, eg. March 2010 YTD, i get wrong values for entities. But, apart from YTD, i get absolutely correct values if i select measures as anually, quarterly or monthly. I have checked ISBEGINNING proper