How to get the background of a cell when clicked

Hi all,
I need to know how I can get the background color of each cell when mouse clicked, I need that because I have to send that color to another table show the whole table with the same background.
Any ideas?
For the source table cell I am using this renderer:
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
public class ColorRenderer extends JLabel implements TableCellRenderer {
    public ColorRenderer() {
        setOpaque(true);
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if (value != null) {
            setText(value.toString());
        if (isSelected) {
            setBackground(table.getSelectionBackground());
            setForeground(table.getSelectionForeground());
        } else {
            setBackground(new Color(181, 198, 223));
            setForeground(Color.black);
            boolean theSame = true;
            for (int i = 1; i <= row; i++) {
                if (!table.getValueAt(i, 0).toString().equals(table.getValueAt(i - 1, 0).toString())) {
                    theSame = !theSame;
                    break;
            if (!theSame) {
                setBackground(new Color(239, 206, 179));
        return this;
}

how I can get the background color of a cell when mouse clickedAttach a mouseListener to your table. In that listener find the clicked cell through myTable.rowAtPoint(MouseEvent.getPoint()) dto. with column.
Then myTable.getCellRenderer(int row, int column), and in the renderer you look for the colour.

Similar Messages

  • How to get the coordinate of a cell in the jtable?

    How to get the coordinate of a cell in the jtable?
    How to get the point of a cell in the jtable?
    Thanks for help!

    getCellRect(...);

  • How to display the details of particular order when click on button in sapui5

    Hi Experts,
        How to display the details of particular order when click on button in sapui5?
    I Have a requirement that is i want display all the list of orders coming from backend as shown in image below
    then in that i have a button when i press the button  it need to display the details of particular order as shown in image below
    Please help me .
    Thanks & Regards
    chitti

    Does anyone know how to display the index of current desktop?
    Brute force - - I have written the number of the Desktop directly onto the wallpaper picture I am using for each Desktop  (easy to do with Preview).
    All Desktops are using different wallpaper photos, so they are easily recognized by the color scheme, and in the upper left corner is the number.
    Regards
    Léonie

  • How to get the last received notification timestamp when app in background

    Hi All,
    We are developing the app in windows phone Silverlight 8.1.
    We need to show the last received notification time stamp even when the app is in background.
    When the app in foreground, I can get the timestamp.
    Since we cant write the background task for the Silverlight phone 8.1 app, I don't know how to get the time stamp of the last
    notification(toast/livetile/badge) in the app for display.
    Can anyone help on this.
    Thanks,
    Meena

    Yes, continuous background execution is not supported but you can use background tasks. 
    (Continuous background execution in this context refers to the special run state permitted for GPS Navigation apps.)
    For information regarding Background Tasks see: Supporting your app with background tasks -
    http://msdn.microsoft.com/library/windows/apps/hh977046.aspx
    Additional information is available in these topics:
    Guidelines for background tasks
    PushNotificationTrigger
    How to receive raw notifications
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • How to get the name of a cell style

    Hi, All,
    I have a question about how to get the cell style name used by each cell in a table.
    I looked at all the fonctions provides by: ICellStylesFacade and ITableStylesFacade, but I did not find the fonction I need.
    Can someone give me some advises?
    Thanks in advance!!

    String myFileName = request.getRequestURL().substring(request.getRequestURL().lastIndexOf("/")+1);
    or with javascript
    <H1><script>document.write(document.location.href.substring(document.location.href.lastIndexOf("/")+1))</script></H1>
    bye! :)

  • How to get the Background job name

    Hi,
    I am executing a report in background and i want to get the background job name in the same report program. How can i get the same.
    Regards,
    Rajgopal Dara.

    Hi,
    for this fm is used 148 times in our system, I made a check program and it works:
    report  zsbatchfm.
                                                                                    data: xv_jobcn type btcjobcnt.
    data: xv_jobnm type btcjob.
    data: xv_stepc type btcstepcnt.
                                                                                    call function 'GET_JOB_RUNTIME_INFO'
      importing
    *   EVENTID                       =
    *   EVENTPARM                     =
    *   EXTERNAL_PROGRAM_ACTIVE       =
        jobcount                      = xv_jobcn
        jobname                       = xv_jobnm
        stepcount                     = xv_stepc
      exceptions
        no_runtime_info               = 1
        others                        = 2.
                                                                                    if sy-subrc <> 0.
      write:  /1 'SY-SUBRC = ', sy-subrc.
    else.
      write:  /1 'JOBCOUNT  = ', xv_jobcn.
      write:  /1 'JOBNAME   = ', xv_jobnm.
      write:  /1 'STEPCOUNT = ', xv_stepc.
    endif.
                                                                                    commit work.
    In online mode you get a SUBRC = 1, in batch mode you get the informations (here: in SPOOL)
    Please check it on your system!
    Regards,
    Klaus

  • How to get the table/tree/list cell underneath the mouse

    I feel like I must be missing something. How can I find out the tree cell underneath the mouse cursor?
    I am implementing drag and drop from a table to a tree. I need to know which tree cell the user dropped the item on. I can get the drop coordinates (in pixels, I assume) from the drag event, but there doesn't seem to be a way to convert that into the particular cell index. This same question applies to getting the list and table cell under at particular coordinates.
    If there isn't an API for this, has anyone found a reliable workaround (dividing Y by cell height, etc.)
    Thanks,
    Josh

    You need to put event handlers for the D&D events on the Cells that are being created (so you will need to set a custom cell factory). For example, every cell is a Node, and these support properties like 'onDragDroppedProperty', and 'onDragExitedProperty'.
    When you add event handlers to these, you should be notified of items being dragged onto specific Cells of the Tree. A Cell then can be matched with a particular item in the Tree by reading its TreeItem property.
    Also read the documentation for TreeItem. There is a bit there that says:
    "It is important to note however that a TreeItem is not a Node, which means that only the event types defined in TreeItem will be delivered. To listen to general events (for example mouse interactions), it is necessary to add the necessary listeners to the cells contained within the TreeView (by providing a cell factory)."
    Which gives a clear hint at the end that for other interactions, you should add listeners to the Cells.
    Good luck!

  • How to get the cummilative values for Cell Definitions

    Hi Experts,
    We have a cell definition used to calculate the row and columns. i have used the stucture to calculate the cumilative year(from first month to current month) but in output I am unable to get the cummulative year value for this cell definition.its returning no values !!!
    How can i achieve to calculated the cumilative values for the cell definifion.
    Regards
    Suraj
    Message was edited by:
            suraj kumar
    null

    Suraj,
    Is your formula to add up the various values in your Structure or in your Cell editor?
    I suspect you may have to use a formula in your Cell Editor.
    Regards
    Gill

  • How to get the value from a cell in jTable without click "enter" or "tab"

    Hi guys,
    I have a simple question. I have a jTable in my screen and when editing a value, but without click "enter" or "tab" I want to get the new value. I have a button update and after editing the value I click the button "update" and I want the new value to be store in my table. If try to get the selected value it is giving the old value. How can I implement this? Any idea? I hope I was clear.
    Thanks

    [Table Stop Editing|http://www.camick.com/java/blog.html?name=table-stop-editing]

  • How to get the Status code of rwclient when run as a background job

    Hi all,
    i have to get the return code(status code) of the rwclient.exe while running as a batch script. is it possible to get the return code to check whether the report generated succefully or not?
    please help me if anyone has the solution.
    Thanks in advance
    Deena

    Hi Andi,
    Please see my Blog : /people/dhanabal.thangavel2/blog/2009/12/16/getting-daily-failed-message-list-in-xi-and-sending-an-alert-mail-with-attachementcsv-file-of-that-list
    I think it 'll help you on this.
    Cheer,
    Dhanabal

  • How to get the values of a selectManyCheckBox when that is in h:dataTable

    Hello,
    I have a jsp page. in that user can choose multile checkboxes and these checkboxes labled as Current, Mailing, PosibleMailing, length is 3 fixed.
    And i am displaying this in a <h:dataTable> this datatable length depends upon the users there may be more than 1 user, for every user there is multiplecheckbox with length 3(fixed).
    code is look like this
    <h:dataTable value="#{InvestigationDefendantView.investDefsFindingsModel}" var="def" border="0" >
    <h:column>
    <h:selectManyCheckbox value="#{InvestigationDefendantView.addtype1}" disabled="false">
    <f:selectItem itemValue="Current" itemLabel="Current"/>
    <f:selectItem itemValue="Mailing" itemLabel="Mailing"/>
    <f:selectItem itemValue="Posible" itemLabel="Posible"/>
    <j4j:idProxy id="DefAddTypeProxy"/>
    </h:selectManyCheckbox>
    </h:column>
    </h:dataTable>
    here abovevalue="#{InvestigationDefendantView.investDefsFindingsModel}" suppose 3(we can assume) then there are 3 pairs of selectManyCheckBoxes are there in my jsp page.
    So u can assume in my jsp page checkboxes are look like 3*3 Matrix
    from my backing bean i am fetching the values of this checkboxes with the below code
    java code:
    InvestDefAddressTypeGetter inv = new InvestDefAddressTypeGetter();
    InvestDefAddressTypeBean[] inb = inv.get(pID);
    this.fMap = new HashMap<String, ArrayList<String>>();
    for(int i=0; i<inb.length; i++)
    String str1 = inb.getGivenDefID().toString();
    this.fdefid.add(str1);
    this.fGivenDefID.add(inb[i].getGivenDefID());
    String addType = inb[i].getAddType();
    Logger.info(this, "adding type value", addType);
    this.fdefid.add(str1);
    this.faddType.add(addType);
    Logger.info(this, "length of strings", this.faddType);
    this.fMap.put(str1, this.faddType);
    i am fetching the checkboxes value through my get method
    public String[] getAddtype1() throws SQLException, SearchException
    Logger.info(this, "addtype testing", this.faddType.size());
    if (this.faddType.size() > 0 )
    ArrayList<String> alcb = new ArrayList<String>();
    for (int i = 0; i < this.faddType.size(); i++)
    alcb.add(this.faddType.get(i));
    String[] tempArr = new String[alcb.size()];
    for (int i = 0; i < alcb.size(); i++)
    tempArr[i] = alcb.get(i).intern();
    return tempArr;
    return new String[0];
    from the above code if i have clicked (you can assume 3*3 matrix here) 1*1, 1*2 and 2*1 and 2*2and saving the value in database records are saved as per requirement but when i am editing the records with the above code i am getting 1*1, 1*2 and 2*1, 2*2 and 3*1, 3*2 checked but i did not checked the 3*1 and 3*2 ckeck boxes.
    Because the same get method will be called in the multipleckeck boxes. how can i prevent does not display the unchecked value from my backing bean.
    Please anybody help me in this issue.

    Is this you? [http://forums.sun.com/thread.jspa?threadID=5335038].

  • How to get the location of a pageitem when there are pageitems with same UID?

    There are two text frames with same UID but on different pages( also defferent spreads ). What I want to know is how I can get the location of them both.
    The following code can only get the location of the first frame because the second frame has the same UIDRef with the first one(because they are in one document with same UID) .
        InterfacePtr<IGeometry> splineGeo(ItemRef, IID_IGEOMETRY);
        PMMatrix itemPMMatrix = ::InnerToPasteboardMatrix( splineGeo );
        PMRect  itemPMRect = itemGeo->GetStrokeBoundingBox( itemPMMatrix );
    Is there any way I can get the second frame location?
    Thanks a lot.

    No.
    Just copy the pageitems from master page to document page.

  • How to get the addition DML Error information when using PL/SQL?

    Given the following statements:
    drop table bob;
    create table bob
    col1 number(6,2),
    col2 number(6,2) not null
    insert into bob(col1, col2) values (123.12, null);
    insert into bob(col1, col2) values (123.12, 12345.12);
    commit;
    I get different behavior from Oracle error messages.
    Here is the sample output:
    Table dropped.
    Table created.
    insert into bob(col1, col2) values (123.12, null)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("BOB"."COL2")
    insert into bob(col1, col2) values (123.12, 12345.12)
    ERROR at line 1:
    ORA-01438: value larger than specified precision allows for this column
    Commit complete.
    Note that in the first error (1400) the generated error message contains the name of the problematic column ("BOB"."COL2"). Also note that in the regurgitated statement the error pointer (*) is at the far left. In this case, the regurgitated statement is of no use to me because the error message identifies the culprit column.
    However, in the second error (1438) the generated error message is very generic and does NOT indicate the problematic column. In addition, in this case the error pointer (*) of the regurgitated statement has moved to point to the troublesome column. In this case, I must use BOTH the error message and the regurgitated statement to completely understand the problem.
    This difference in how error messages are constructed causes difficulty within PL/SQL. If PL/SQL happens to generate a 1400 error message, then simply capturing the error message and giving it to the user provides enough information for him/her to solve the problem. However, if a 1438 error is generated then the resulting error message has insufficient information for the user to pursue the problem.
    So my question is, within PL/SQL do you know how to get your hands on Oracle's regurgitated statements so that they can be presented to the user to assisted him/her in problem resolution?
    Thanks.

    I don't think it's that easy. Notice that if you put the insert into an actual pl/sql block, you don't get the correct column pointer anymore.
    BEGIN insert into bob(col1, col2) values (123.12, 12345.12); END;
    ERROR at line 1:
    ORA-01438: value larger than specified precision allows for this column
    ORA-06512: at line 1
    Richard

  • How to get the Organizer page to install when only the Editor page appeared after Elements12 installation?

    I  Can't figure out if it is possible to retrieve/install the Organizer page after only the Editor page installed on Elements 12. If it is possible, how do I do it?

    When I launch PSE 12 directly I do get the "welcome" screen first. If I then click on the Organizer box it gives the moving line for a bit, and then nothing more: no Organizer screen ever appears. However when I click on the Editor box the Editor screen does come up after the moving line starts.
    By the way, I've long used PSE 10, and that still works for both screens, so I'm now having to jerryrig the post production process by using the Organizer screen from version 10 to access my photos and then drag them to the Editor screen from version 12 !
    I bought PSE 12 because it accomodates/processes/edits in  RAW, where version 10 doesn't. I sure don't want to have to pay for version 13, and Adobe chat no longer supports version 12, so any help you can offer would be wonderful !!!
    By the way -- in addition, a very useful  plug-in (Nik Collection) that i've come to love to use with version 10 doesn't appear with version 12's Editor screen at all. So if you have any thoughts about how to fix that I would really appreciate that too !
    Thanks in advance. -- Jessie
    Sent via the Samsung Galaxy Note® II, an AT&T 4G LTE smartphone

  • How to change the background of a JPanel when printing?

    I have a JPanel that has a background color of gray when displayed on the screen. I would like to change the background to white when printing but leave it gray on the screen. I am calling setBackground(), clearRect() and fillRect() but it still prints out with the gray background. Any thoughts on what method I could call to change this?
    public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
    if (pageIndex >= 1) {
    return Printable.NO_SUCH_PAGE;
    double pageHeight = pf.getImageableHeight();
    double pageWidth = pf.getImageableWidth();          
    Graphics2D g2 = (Graphics2D) g;
    g2.setBackground(Color.white);
    g2.clearRect((int)pageWidth/2, (int)pageHeight/2, (int)pageWidth, (int)pageHeight);
    g2.fillRect((int)pageWidth/2, (int)pageHeight/2, (int)pageWidth, (int)pageHeight);
    paint(g2);

    From reading the doc, it appears that you have to change the background color of the Component:
    setBackground
    public abstract void setBackground(Color color)
    Sets the background color for the Graphics2D context. The background color is used for clearing a region. When a Graphics2D is constructed for a Component, the background color is inherited from the Component. Setting the background color in the Graphics2D context only affects the subsequent clearRect calls and not the background color of the Component. To change the background of the Component, use appropriate methods of the Component.
    Parameters:
    color - the background color that isused in subsequent calls to clearRect
    See Also:
    getBackground(), Graphics.clearRect(int, int, int, int)
    V.V.

Maybe you are looking for

  • Stock balances by location

    Hi I wonder if you can help. I have ran tcode MB5L which provides me with a list of all stock by material code, providing quantity and value. In order to find out which storage location, I can double click on the items, and it shows the storage locat

  • Can using a Macbook Pro Drive in a Mac Pro cause kernel panic?

    Is there any inherent problem/conflict with running a Mac Pro off an OSX drive that was used, for a Macbook Pro? Is there MP firmware installed that is incompatible with a MBP drive? The drive is a 2.5" duplicate of my MBP that was created not by ins

  • .pdf's won't print to hp with ps printer driver

    I'm on win7 64 using acrobat pro 11, trying to print to a networked hp laserjet 3015 with hp's universal postscript printer driver. I didn't have this issue with the pcl5 driver, but it wouldn't allow me to print more that one copy at a time, so I sw

  • Is there a way to enter a link & have it go to a specific spot on the page?

    hi, i have a long list of items and i want to have a directory at the top of the page.. then a person can click on an item and it takes them to the middle of the page or so... then a link that says "top of page" underneath the items.. is this possibl

  • Add Social Media or "Share" buttons to my blog

    I would like to add share buttons (facebook, twtiter) to my blog, right under the title and date of each article. Where can I add this? Is there a tuturial available for this?