How can I change the coIor of one cell in a JTable

Hello,
I need to change the colours of the cells in a table. The problem is that when I try to change the colour of a one cell the colour of entire column is changed. See the way that I tried to use.
TableCellRenderer cr = table.getCellRenderer(row, col);
if (cr instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)cr).setBackground(bgColor);
......Please let me know if you have any suggestion
Thanks a lot
Jan

try this ...
In ur table call this
ColorRenderer cell=new ColorRender();
// for(int i=0;i<table.getModel().getColumnCount();i++){
// TableColumn mod=this.getColumn((this.getModel().getColumnName(i)));
mod.setCellRenderer(cell);
And ur ColorRender calss should override DefaultTableCellRenderer like this
class ColorRenderer extends DefaultTableCellRenderer {
protected int align;
public ColorRenderer(int align) {
this.align=align;
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
setHorizontalAlignment(align);
super.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
if(col==4){
setBackground(Color.cyan);
return this;

Similar Messages

  • How can I change the setting to one appropriate to java1.2

    Hello.
    I am using WebLogic 4.5.1 .
    and recently started to use JDK 1.2 instead of JDK 1.1.7.
    So, I set [start]-[weblogic]-[Choose1.2JRE] in environment.
    and then, if I execute T3Server, the message of
    "javai.dll class path cannot be found " is displayed and the server is not
    loaded.
    However, javai.dll was in java1.1.X\bin.
    I can assume that a setting is to java1.1.X.
    --> How can I change the setting to one appropriate to java 1.2
    It's my environment
    ClassPath
    .;c:\weblogic\classes;C:\weblogic\lib\weblogicaux.jar;C:\weblogic\license;c:
    \weblogic;C:\weblogic\myserver\clientclasses;C:\weblogic\myserver\serverclas
    ses;C:\weblogic\myserver\servletclasses;C:\weblogic\mssqlserver4\classes;c:\
    weblogic\classes\boot;C:\weblogic\eval\cloudscape\lib\cloudscape.jar;c:\rmi-
    iiop\lib\iioprt11.jar;c:\rmi-iiop\lib\iioprt.jar;c:\rmi-iiop\lib\rmiorb.jar;
    C:\jsdk2.1\runner.jar;C:\jsdk2.1\servlet.jar
    Path :
    %SystemRoot%\system32;C:\jdk1.3bin;c:\weblogic;c:\weblogic\bin;
    c:\;c:\bat;c:\util\;C:\jsdk2.0\bin
    Hyung Gi Min

  • How can I change the gain on one audio track in the selection?

    How can I change the gain on one audio track in the selection? Is there a way to adjust the gain as it is implemented for example in cubase - pull waveform up and gain varies?

    I'm not sure what you mean by "in the selection", or, more honest: I don't understand that at all.
    So, instead I'm going to tell you that you can indeed adjust the Gain of one or more selected region(s) in the Region inspector on the left hand side.

  • How can i change the data from one Time Capsule to another?

    How can i change the data from one Time Capsule to another?

    Do you mean copy it?  If so, see #18 in Time Machine - Frequently Asked Questions  You'll need section 2 there.
    If you mean something else, please clarify.

  • HOw can i change the color of a cell

    How can I change the color of a cell when it is selected. I select the cell by pressing enter, then I want the text in the cell to change color to red, but all the cells in the table change color. Please I would be grateful for some help

    Subclass DefaultTableCellRenderer.
    public class MyCellRenderer extends DefaultTableCellRenderer
    Override
    public Componet getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    JLabel lab = new JLabel(String)value);
    lab.setOpaque(true);
    return lab;
    if(isSelected)
    lab.setBackground(Color.red);
    else
    lab.setBackground(Color.white);
    Set the columns in your table:
    table.getCoulumModel.getColumn(0).setCellRenderer(new myCellRenderer());
    table.getCoulumModel.getColumn(1).setCellRenderer(new myCellRenderer());
    etc. for each column in your table.

  • How can i pull the value of one cell into the cell of another table?

    I want to pull the value (the result of a =SUM(x) formula as the starting value of a column in another table.  How can I do that?

    Yvan KOENIG (VALLAURIS, France) vendredi 10 février 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

  • How can I change the language of a cell or an entire spreadsheet?

    The HELP says
    click Inspector in the toolbar, click the Text button, and then click More. Select a language from the Language pop-up menu.
    However, there is no MORE button (as in PAGES).
    Is the only chance via setting the input language to English in the system settings menu?
    thanks!

    As I never enter the Help but "Numbers User Guide, I never saw these sentences.
    They are just the result of a bad copy/paste from thr Pages Help.
    In Numbers, the language is a global setting.
    There is an application allowing us to set the used language "on the fly" but it changes the Interface language as well as the values one.
    I forgot the name of this app but I'm sure that fruhulda will fill the gap
    Yvan KOENIG (VALLAURIS, France) mercredi 21 décembre 2011 12:30:40
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How can I change the resolution of one monitor in a dual monitor set up?

    I'm trying to help someone set up an extended desktop using two monitors connected to a mac mini. One monitor is at the maximum resolution, but the other is not, and thus feels enlarged or zoomed in. I know a higher resolution is possible because the monitor has a button menu that shows a higher resolution, but it seems to be disabled - as I cannot select the maximum.
    Also can't seem to change it under the mac mini's display preferences.
    Any suggestions? We would really appreciate it.

    This model simultaneously supports 1920x1200 on an HDMI or a DVI display (using the included HDMI-to-DVI adapter) and2560x1600 on a Thunderbolt or Mini DisplayPort display
    The HDMI connection does not support higher than 1920X1200
    What resolutions are running now and on what connection and what is the grayed-out resolution?

  • In Numbers, how can you change the format of a cell on ipad mini?

    I used the paintbrush but the changes are not taking on the ipad mini but it keeps going back to the 'automatic' default.

    Hi Dempb,
    One of the ways this can happen is if the cells you are trying to format are the result of a formula or coming from elswhere in the table. For instance, if I have the formula SUM that is totaling a column formated "currency" I will not be able to change its format to "text".
    What do you want to do? there may be another way to accomplish it.
    Quinn

  • How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    http://support.apple.com/kb/ht5621

  • When my husband and I first bought our iPhones, I was the only one with an Apple ID (since he never used iTunes). He used my apple id to get apps. Now he has his own ID, but my account keeps popping up on his phone. How can we change the ID on his phone?

    When my husband and I first bought our iPhones, I was the only one with an Apple ID (since he never used iTunes). He used my apple id to get apps. Now he has his own ID, but my apple ID email address keeps popping up on his phone when he tries to download an app. We do not want to have all of the same apps on our phones. How can we change the ID on his phone? I already tried going to Settings>iTunes &App Store> and changing the Apple ID to his account email and that did not solve the problem. To make things worse, I recently changed my Apple ID email address (without getting a new ID) and I do not remember my old password (and this is the address that is popping up on his phone). He does not have any music on his phone and all of the Apps that he has are free.  Any help you could offer would be great (-:

    All apps are forever tied to the Apple ID that bought them. To stop your id from popping up, you need to delete the apps on his phone, and then repurchase them under his account.

  • 2 different iphones have the same Apple ID, how can I change the apple ID on one of them but not delete the other iphone's data and media?

    2 different iphones have the same Apple ID, how can I change the apple ID on one of them but not delete the other iphone's data and media?

    You don't have to do anything with the first iPod that you don't use anymore. If you are planning on keeping it, put in a drawer in your house and forget about it.
    You don't need a second account to use with the new iPod. I use one Appl e ID and iTunes library for two iPods, and two iPad. I have different content on all four devices. You can select exactly what you want to sync to each device and it can be different content on all devices.

  • I forgot my password along with the answers to my security questions. So I try sending an E-Mail to myself but the E-Mail I am sending it to isn't even mine, nor the one I have registered. How can I change the E-Mail or something?

    I forgot my password along with the answers to my security questions. So I try sending an E-Mail to myself but the E-Mail I am sending it to isn't even mine, nor the one I have registered. How can I change the E-Mail or something?

    Security questions:
    https://discussions.apple.com/thread/4533485?tstart=0

  • How can I change the itunes store from Swiss to the Italian one on my ipad2 with new software ios6? Thanks

    How can I change the itunes store from Swiss to the Italian one on my ipad2 with new software ios6? Thanks

    See More Like This to the right of this post!

  • Hi! How can I change the shipping address for the program of replacement of the 1 generation ipod nano? I've already received the empty box and now I should send back the old ipod but I'd like to receive the new one to another address. Thank you.

    Hi! How can I change the shipping address for the program of replacement of the 1 generation ipod nano? I've already received the empty box and now I should send back the old ipod but I'd like to receive the new one to another address. Thank you.

    I would contact Apple directly and have them work with to get the iPod shipped to a new/different address.
    http://www.apple.com/contact/
    B-rock

Maybe you are looking for

  • JD3-Error deploying Oracle Java Libraries

    I get the following error when trying to deploy Oracle 8.1.5 JDBC, Connection Manager, and JBO Runtime libraries: initialization complete loading : oracle/sql/converter/CharacterConverter creating : oracle/sql/converter/CharacterConverter loading : o

  • Problem of trigger event for Customer master.

    Hi all, I created one object type in KNA1. because i want to use task instead of the workflow. after i executed the customer master creation , i got this error during the execution."Dereferencing of the NULL reference". if anybody want information, p

  • How do i fix frozen shutter camera

    So i click on the camera and its stays frozen, HELPP

  • Remove the line in component af:panelHeader

    How can I remove the line that comes by default with the component <af:panelHeader>? How to apply custom background color to the panel? For example: <af:panelBox styleClass="panelClass"  rendered="true" width="100%"     background="medium" id="pbBasi

  • Cropping CS6

    The cropping tool does not resize the image, using the drop down menu a 5X7 actually remains at 11.5 X 16.1.  The only way I can get this crop tool to actually resize is to create a crop size and resolution and save it as a preset.  In CS5 you just p