How to add colors to table cells

Hi ALL,
Does anyone have any idea of adding colors to table cells?For example i am displaying monthly chart in a table view i want to fill the cells with colors when columns are saturday and sunday.
Thanks in advance

Hi,
I want to pass the colors at bean level.For example
private DefaultTableViewModel createNewTable
                                  (DefaultTableViewModel model) {
        Vector data = createData();
        Vector colName = new Vector();
        /* Define column names */
        colName.addElement("1stColumn");
        colName.addElement("2ndColumn");
        colName.addElement("3rdColumn");
        model = new DefaultTableViewModel(data, colName);
        return model;
    private Vector createData() {
        Vector dataVec = new Vector();
        Vector retVector = new Vector();
        /* 1st entry */
        dataVec.addElement("Row 1, Column 1");
        dataVec.addElement("Row 1, Column 2");
        dataVec.addElement("Row 1, Column 3");
        retVector.addElement(dataVec);
        /* 2nd entry */
        dataVec = new Vector();
        dataVec.addElement("Row 2, Column 1");
        dataVec.addElement("Row 2, Column 2");
        dataVec.addElement("Row 2, Column 3");
        retVector.addElement(dataVec);
        /* more entries */
        return retVector;
suppose I want to pass the color at Row2,Column1.Can anyone post the sample code ?
its little urgent.Thanks in advance

Similar Messages

  • In alvs how to add colore

    how to add colore to the particular fields in alvs?
    could u plz explain clearly with code and comments

    Hi,
    go thr below code,
    tables used -
    tables: mkpf,
            mseg,
            lfa1,
            makt.
    global hashed tables used
    data: begin of wa_mkpf, "header
          mblnr like mkpf-mblnr,
          mjahr like mkpf-mjahr,
          budat like mkpf-budat,
          xblnr like mkpf-xblnr,
          end of wa_mkpf.
    data: ht_mkpf like hashed table of wa_mkpf
          with unique key mblnr mjahr
          with header line.
    data: st_mkpf like standard table of wa_mkpf
          with header line.
    data: begin of wa_mseg, " line items
          mblnr like mseg-mblnr,
          mjahr like mseg-mjahr,
          zeile like mseg-zeile,
          bwart like mseg-bwart,
          charg like mseg-charg,
          matnr like mseg-matnr,
          lifnr like mseg-lifnr,
          erfmg like mseg-erfmg,
          erfme like mseg-erfme,
          end of wa_mseg.
    data ht_mseg like hashed table of wa_mseg
          with unique key mblnr mjahr zeile
          with header line.
    data st_mseg like standard table of wa_mseg
          with header line.
    cache structure for lfa1 records
    data: begin of wa_lfa1,
          lifnr like lfa1-lifnr,
          name1 like lfa1-name1,
          end of wa_lfa1.
    data ht_lfa1 like hashed table of wa_lfa1
          with unique key lifnr
          with header line.
    cache structure for material related data
    data: begin of wa_material,
          matnr like makt-matnr,
          maktx like makt-maktx,
          end of wa_material.
    data: ht_material like hashed table of wa_material
            with unique key matnr
            with header line.
    result table
    data: begin of wa_lst, "
          budat like mkpf-budat,
          mblnr like mseg-mblnr,
          lifnr like mseg-lifnr,
          name1 like lfa1-name1,   
          xblnr like mkpf-xblnr,
          zeile like mseg-zeile,
          charg like mseg-charg,
          matnr like mseg-matnr,
          maktx like makt-maktx,
          erfmg like mseg-erfmg,
          erfme like mseg-erfme,
          mjahr like mseg-mjahr,
          end of wa_lst.
    data: ht_lst like hashed table of wa_lst
            with unique key mblnr mjahr zeile
            with header line.
    data: begin of wa_lst1, " sumary by material
          matnr like mseg-matnr,
          maktx like makt-maktx,
          erfmg like mseg-erfmg,
          erfme like mseg-erfme,
          color_line(4) TYPE c,           " Line color
          color_cell    TYPE lvc_t_scol,  " Cell color
          celltab type LVC_T_STYL,
          end of wa_lst1.
    data: ht_lst1 like hashed table of wa_lst1
            with unique key matnr
            with header line.
    structures for alv grid display.
    itabs
    type-pools: slis.
    data: it_lst            like standard table of wa_lst with header line,
          it_fieldcat_lst   type slis_t_fieldcat_alv with header line,
          it_sort_lst       type slis_t_sortinfo_alv,
          it_lst1           like standard table of wa_lst1 with header line,
          it_fieldcat_lst1  type slis_t_fieldcat_alv with header line,
          it_sort_lst1      type slis_t_sortinfo_alv.
    structures
    data: wa_sort         type slis_sortinfo_alv,
          ls_layout       type slis_layout_alv.
    color management.
    DATA  : wa_color    TYPE lvc_s_scol.
    Internal table for color management.
    DATA : it_color    TYPE TABLE          OF lvc_s_scol.
    itab for input enabling.
    DATA: lt_celltab TYPE lvc_t_styl. "
    global varialbes
    data: g_lines type i.
    data: g_repid like sy-repid,
          ok_code       like sy-ucomm.
    selection-screen
    "text: Dates:
    select-options: so_budat for mkpf-budat default sy-datum.
    "text: Material numbers.
    select-options: so_matnr for mseg-matnr.
    selection-screen uline.
    selection-screen skip 1.
    "Text: show summary by material.
    parameters: gp_bymat as checkbox default ''.
    parameters: gp_hier  as checkbox default 'X'.
    start-of-selection.
      perform get_data.
      perform show_data.
    end-of-selection.
          FORM get_data                                                 *
    form get_data.
            select mblnr mjahr budat xblnr
                into table ht_mkpf
               from mkpf
              where budat in so_budat. " make use of std index.
    have we retrieved data from mkpf?
      describe table ht_mkpf lines g_lines.
      if g_lines > 0.
    if true then retrieve all related records from mseg.
    Doing this way we make sure that the access is by primary key
    of mseg.
    The reason is that is faster to filter them in memory
    than to allow the db server to do it.
        select mblnr mjahr zeile bwart charg
                 matnr lifnr erfmg erfme
          into table ht_mseg
          from mseg
            for all entries in ht_mkpf
         where mblnr = ht_mkpf-mblnr
           and mjahr = ht_mkpf-mjahr.
      endif.
    fill t_lst or t_lst1 according to user's choice.
      if gp_bymat = ' '.
        perform fill_ht_lst.
      else.
        perform fill_ht_lst1.
      endif.
    endform.
    form fill_ht_lst.
      refresh ht_lst.
    Example: how to discard unwanted data in an efficient way.
      loop at ht_mseg.
      filter unwanted data
        check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
        check ht_mseg-matnr in so_matnr.
      read header line.
        read table ht_mkpf with table key mblnr = ht_mseg-mblnr
        mjahr = ht_mseg-mjahr.
        clear ht_lst.
    * note : this may be faster if you specify field by field.
        move-corresponding ht_mkpf to ht_lst.
        move-corresponding ht_mseg to ht_lst.
        perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
        perform read_material using ht_mseg-matnr changing ht_lst-maktx.
        insert table ht_lst.
      endloop.
    endform.
    form fill_ht_lst1.
    data: colorear.
      refresh ht_lst1.
    Example: how to discard unwanted data in an efficient way.
             hot to simulate a collect in a faster way
      loop at ht_mseg.
      filter unwanted data
        check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
        check ht_mseg-matnr in so_matnr.
    * note : this may be faster if you specify field by field.
        read table ht_lst1 with table key matnr = ht_mseg-matnr
        transporting erfmg.
        if sy-subrc <> 0. " if matnr doesn't exist in sumary table
        " insert a new record
          clear ht_lst1.
          ht_lst1-matnr = ht_mseg-matnr.
          perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
          ht_lst1-erfmg = ht_mseg-erfmg.
          ht_lst1-erfme = ht_mseg-erfme.
          if colorear = ''.
            colorear = 'X'.
            refresh it_color.
            ht_lst1-color_cell[] = it_color[].
            MOVE 'C410' TO ht_lst1-color_line.
          else.
            colorear = ' '.
            refresh it_color. clear it_color.
            MOVE 'MATNR' TO wa_color-fname.
            MOVE '6'         TO wa_color-color-col.
            MOVE '1'         TO wa_color-color-int.
            MOVE '1'         TO wa_color-color-inv.
            APPEND wa_color TO it_color.
            MOVE 'MAKTX' TO wa_color-fname.
            MOVE '3'         TO wa_color-color-col.
            MOVE '1'         TO wa_color-color-int.
            MOVE '1'         TO wa_color-color-inv.
            APPEND wa_color TO it_color.
            MOVE 'ERFMG' TO wa_color-fname.
            MOVE '5'         TO wa_color-color-col.
            MOVE '1'         TO wa_color-color-int.
            MOVE '1'         TO wa_color-color-inv.
            APPEND wa_color TO it_color.
            ht_lst1-color_cell[] = it_color[].
            clear ht_lst1-color_line.
          endif.
          insert table ht_lst1.
        else." a record was found.
        " collect erfmg.  To do so, fill in the unique key and add
        " the numeric fields.
          ht_lst1-matnr = ht_mseg-matnr.
          add ht_mseg-erfmg to ht_lst1-erfmg.
          modify table ht_lst1 transporting erfmg.
        endif.
      endloop.
    endform.
    implementation of cache for lfa1.
    form read_lfa1 using p_lifnr changing p_name1.
            read table ht_lfa1 with table key lifnr = p_lifnr
            transporting name1.
      if sy-subrc <> 0.
        clear ht_lfa1.
        ht_lfa1-lifnr = p_lifnr.
        select single name1
           into ht_lfa1-name1
          from lfa1
        where lifnr = p_lifnr.
        if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
        insert table ht_lfa1.
      endif.
      p_name1 = ht_lfa1-name1.
    endform.
    implementation of cache for material data
    form read_material using p_matnr changing p_maktx.
      read table ht_material with table key matnr = p_matnr
      transporting maktx.
      if sy-subrc <> 0.
        ht_material-matnr = p_matnr.
        select single maktx into  ht_material-maktx
          from makt
         where spras = sy-langu
           and matnr = p_matnr.
        if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
        insert table ht_material.
      endif.
      p_maktx = ht_material-maktx.
    endform.
    form show_data.
      if gp_hier = 'X'. "no anda.
       perform show_hierarchicalALV.
      else.
        if gp_bymat = ' '.
          perform show_ht_lst.
        else.
          perform show_ht_lst1.
        endif.
      endif.
    endform.
    form show_hierarchicalALV.
    st_mkpf[] = ht_mkpf[].
    st_mseg[] = ht_mseg[].
    call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    exporting
      I_INTERFACE_CHECK              = ' '
      I_CALLBACK_PROGRAM             =
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      IS_LAYOUT                      =
      IT_FIELDCAT                    =
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
       i_tabname_header               =
       i_tabname_item                 =
      I_STRUCTURE_NAME_HEADER        =
      I_STRUCTURE_NAME_ITEM          =
       is_keyinfo                     =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_BUFFER_ACTIVE                =
      I_BYPASSING_BUFFER             =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      tables
        t_outtab_header                = st_mkpf
        t_outtab_item                  = st_mseg
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform.
    form show_ht_lst.
      "needed because the FM can't use a hashed table.
      it_lst[] = ht_lst[].
      perform fill_layout using 'full display'
                           changing ls_layout.
      perform fill_columns_lst.
    perform sort_lst.
      g_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program       = g_repid
                i_callback_pf_status_set = 'SET_PF_STATUS'
                is_layout                = ls_layout
                it_fieldcat              = it_fieldcat_lst[]
               it_sort                  = it_sort_lst
           tables
                t_outtab                 = it_lst
           exceptions
                program_error            = 1
                others                   = 2.
    endform.
    form show_ht_lst1.
      "needed because the FM can't use a hashed table.
      it_lst1[] = ht_lst1[].
      perform fill_layout using 'Sumary by matnr'
                           changing ls_layout.
      perform fill_columns_lst1.
    perform sort_lst.
      g_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program       = g_repid
                i_callback_pf_status_set = 'SET_PF_STATUS'
                is_layout                = ls_layout
                it_fieldcat              = it_fieldcat_lst1[]
               it_sort                  = it_sort_lst
           tables
                t_outtab                 = it_lst1
           exceptions
                program_error            = 1
                others                   = 2.
    endform.
    form fill_layout using p_window_titlebar
                   changing cs_layo type slis_layout_alv.
      clear cs_layo.
      cs_layo-window_titlebar        = p_window_titlebar.
      cs_layo-edit                   = 'X'.
      cs_layo-edit_mode              = space.
      MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
    Field that identify cell color in inetrnal table
      MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
    move 'CELLTAB' TO cs_layo-stylefname.
    endform.                    " armar_layout_stock
    form set_pf_status using rt_extab type slis_t_extab.
    create a new status
    and then select extras -> adjust template -> listviewer
      set pf-status 'VISTA'.
    endform.        "set_pf_status
    define add_lst.
      clear it_fieldcat_lst.
      it_fieldcat_lst-fieldname     = &1.
      it_fieldcat_lst-outputlen     = &2.
      it_fieldcat_lst-ddictxt       = 'L'.
      it_fieldcat_lst-seltext_l       = &1.
      it_fieldcat_lst-seltext_m       = &1.
      it_fieldcat_lst-seltext_m       = &1.
      if &1 = 'MATNR'.
        it_fieldcat_lst-emphasize = 'C111'.
      endif.
      append it_fieldcat_lst.
    end-of-definition.
    define add_lst1.
      clear it_fieldcat_lst.
      it_fieldcat_lst1-fieldname     = &1.
      it_fieldcat_lst1-outputlen     = &2.
      it_fieldcat_lst1-ddictxt       = 'L'.
      it_fieldcat_lst1-seltext_l       = &1.
      it_fieldcat_lst1-seltext_m       = &1.
      it_fieldcat_lst1-seltext_m       = &1.
      append it_fieldcat_lst1.
    end-of-definition.
    form fill_columns_lst.
    set columns for output.
      refresh it_fieldcat_lst.
      add_lst 'BUDAT' 10.
      add_lst   'MBLNR' 10.
      add_lst  'LIFNR' 10.
      add_lst  'NAME1' 35.
      add_lst  'XBLNR' 15.
      add_lst    'ZEILE' 5.
      add_lst    'CHARG' 10.
      add_lst   'MATNR' 18.
      add_lst   'MAKTX' 30.
      add_lst   'ERFMG' 17.
      add_lst   'ERFME' 5.
      add_lst   'MJAHR' 4.
    endform.
    form fill_columns_lst1.
    set columns for output.
      refresh it_fieldcat_lst1.
      add_lst1 'MATNR' 18.
      add_lst1 'MAKTX' 30.
      add_lst1 'ERFMG' 17.
      add_lst1 'ERFME' 5..
    endform.
    Horacio Zapettini
    Program to Calculate FI Opening Balance
    How to find the Opening balance for a given period in FI Module for a Particular GL A/c.
    I was calculated opening balance, code is below maybe it will be helpful.
    *find period.
      CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
        EXPORTING
          i_date         = s_budat-low
          i_periv        = i_tab-periv                          "'K4'
        IMPORTING
          e_buper        = v_donem
          e_gjahr        = v_gjahr
        EXCEPTIONS
          input_false    = 1
          t009_notfound  = 2
          t009b_notfound = 3
          OTHERS         = 4.
    *calc opening balance hesabý
      SELECT * FROM knc1 WHERE kunnr = i_tab-kunnr
                         AND bukrs = i_tab-bukrs " s_bukrs
                         AND gjahr EQ v_gjahr.
        v_dnm = v_donem.
    opening balance first calc > old year ,
        WHILE v_dnm > 1.
          v_dnm = v_dnm - 1.
          CONCATENATE 'knc1-um' v_dnm 's' INTO v_field_name_borc.
          CONCATENATE 'knc1-um' v_dnm 'h' INTO v_field_name_alacak.
          ASSIGN (v_field_name_borc) TO  old
    add days which is from selected date-low month
        IF v_donem > 1.
          v_dnm = v_donem - 1.
        ELSE.
          v_dnm = v_donem.
        ENDIF.
        SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv    "'K4'
                                     AND bdatj = s_budat-low+0(4)
                                     AND poper = v_dnm.
        t009b-butag = t009b-butag + 1.
        IF s_budat-low+6(2) NE t009b-butag.
          v_date_high = s_budat-low - 1.
          IF v_donem = 1.
            v_date_low = s_budat-low.
            v_date_low+4(4)  = '0101'.
          ELSE.
            CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO
            v_date_low.
          ENDIF.
          SELECT *  FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
                                AND kunnr = i_tab-kunnr
                                AND budat BETWEEN v_date_low AND
                                v_date_high
                                AND umskz = space
                                AND blart IN s_blart.
            IF bsad-shkzg = 'S'.
              i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).
            ELSEIF bsad-shkzg = 'H'.
              i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr   ).
            ENDIF.
          ENDSELECT.
          SELECT *  FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
                               AND kunnr = i_tab-kunnr
                               AND budat BETWEEN v_date_low AND
                               v_date_high
                               AND umskz = space
                               AND blart IN s_blart.
                                 AND gsber IN gsber.
            IF bsid-shkzg = 'S'.
              i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr   ).
            ELSEIF bsid-shkzg = 'H'.
              i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr   ).
            ENDIF.
          ENDSELECT.
        ENDIF.
        "opening balance ( þirket bazlý )z1 degeri
       i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).
    for israel
        i_tab-dmbtril_s = i_tab-dmbtr_s .
        i_tab-dmbtril_h = i_tab-dmbtr_h .
      ENDSELECT.
    reward if useful.

  • Hello, I would like to know how to add or delete single cell in numbers.

    Hello, I would like to know how to add or delete single cell in numbers.

    If by delete you really mean clear the contents of a cell, then just click once on the cell and hit the 'delete' button.
    Before:
    After hitting delete button:
    In some circumstances you can actually delete one cell.
    For example here, I make this choice:
    Resulting in this:
    So it's not strictly true that Numbers does not delete one cell, ever.  It can if you have a one-column table. 
    So never say never or not ever! Enough pedantry for today!
    SG

  • Add image to Table cell

    Hi All,
       Based on condition how can i add image to Table cell.

    Hi,
    Its very simple and straightforward.
    All you need to do is:
    1...Create a context(value attribute) of type string.
    2...I am assuming that you have created a table, and mapped its columns with a node.
    3...In the <i>TableCellEditor</i>  of your desired column, map the above context with the <i>imagesource</i> property.
    4...In the code, set the value of this context to the image name(eg: abc.gif), on satisfying of a condition.
    5...However, keep in mind to set the context value to some default blank image in the doinit() of the view, else, you will get a null pointer exception.
    I hope this solves your problem.
    Keep posting if you have any further queries.
    Regards,
    Hanoz

  • How can I make a table cell extend beyond the page?  The text disappears when the cell becomes larger than the page.

    How can I make a table cell extend beyond a page?  The text disappears when the cell becomes bigger than the page.  I want the table to continue to the next page.

    As a student, you might be able to get Office for Mac from the college bookstore at a substantial discount. Otherwise, I think your best option for documents that need to be shared with Office users is to get one of the free Office clones such as LibreOffice.

  • How to add color only in header

    how to add color only in header and arrange a background color selected from desktop

    You can place rectangle in header section on master page which would be applied on sub pages and then fill rectangle with color.
    If you are after a specific color then simply use color code and fill.
    Thanks,
    Sanjit

  • How to control background color of table cell in an html report?

    I am using Labview 6.1 to generate a report.  In that report there is a table created using the Append Numeric Table to Report VI.  I want to be able to programmatically control the background color of each cell in the table.  Also, how can I programmatically control the background color of the row and header cells of the same table.  I am also generating a second table in the same report using the Append Text Table to Report VI and I would like to programmatically control the background colors of the cells in that table as well.  Thanks.

    Hi epsilon-d...,
    i´m not sure if there is an ready to use function to do what you want, but you can enlarge the available function. Open the "Append Numeric Table to Report.vi" and go to the HTML Case. There you can see another vi which creates the html table. In the VI "HTML Report Table Row" you can add the option: bgcolor="your color" inside of the "TR" tag.
    Hope it helps.
    Mike

  • How can I get a table cell to change color if its below some value

    Hi everyone, I use JDeveloper with JHeadstart and just finished the tutorial using the predefined HR schema. I was wondering how would I go about making the color of a cell to change to red if it falls below 5. So for example if I was to measure the amount of printer cartridges we had in storage, and it falls to below 5, in the table that has the equipment the cell changes color to red?

    You better aks this question on the jdeveloper forum as it is not related to jheadstart.
    Once you know how to do this, this forum can help you woth keeping your page generatable using a custom template.
    See also the chapter on customizing generator output in the jheadstart developers guide.
    Steven davelaar,
    Jheadstart team.

  • Coloring a table cell with swing

    Hello,
    I am trying to write a java program in swing. Basically I am setting up a table and adding labels to the table's cells. Rather than displaying the label, the table is inserting the labels' string value. Here is a compilable example:
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import java.awt.*;
    public class TableTest extends JFrame {
         private final JTable table;
         private final GridBagConstraints constraints;
         private JLabel makeLabel(Color c){
              JLabel lab = new JLabel(" ");
              lab.setOpaque(true);
              lab.setBackground(c);
              //getContentPane().add(lab, constraints);
              return lab;
         public TableTest() {
            super("Visualizer");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            getContentPane().setLayout(new GridBagLayout());
            constraints = new GridBagConstraints();
            constraints.insets = new Insets(3, 10, 3, 10);
            String[] columnNames = {"RED","YELLOW", "BLUE"};
            Object[][] data = { {makeLabel(Color.RED), makeLabel(Color.YELLOW), makeLabel(Color.BLUE) } };       
            table = new JTable(data, columnNames);
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            table.setFillsViewportHeight(true);
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            add(scrollPane);
            pack();
            setVisible(true);
         public static void main(String[] args) {
              new TableTest();
    }How do i modify this to actually show the labels? Thanks in advance.

    Why are you putting labels into the table's cells?
    Have a look at Sun's tutorial on tables to see how a custom renderer is used to display particular cells in a certain way. (And also for the whole rendering approach used by tables.)
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer
    (Swing questions are better asked in the Swing forum: http://forum.java.sun.com/forum.jspa?forumID=57)

  • How to fill color in a cell having particular string when using convertto-html

    Hello Scripters,
    I have downloaded AD health check script but I am wondering if the cell color be changed for a particular string. Like all the cells having text "Failed"..should be in red color.
    Here is the script-
    Function Getservicestatus($service, $server)
    $st = Get-service -computername $server | where-object { $_.name -eq $service }
    if($st)
    {$servicestatus= $st.status}
    else
    {$servicestatus = "Not found"}
    Return $servicestatus
    $Forest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest()
    [string[]]$computername = $Forest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name}
    #Section -1
    $report= @()
    foreach ($server in $computername){
    $temp = "" | select server, pingstatus
    if ( Test-Connection -ComputerName $server -Count 1 -ErrorAction SilentlyContinue ) {
    $temp.pingstatus = "Pinging"
    else {
    $temp.pingstatus = "Not pinging"
    $temp.server = $server
    $report+=$temp
    $b = $report | select server, pingstatus | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Server Availability</h2>" | Out-String
    #Section - 2
    $report = @()
    foreach ($server in $computername){
    $temp = "" | select server, KDC, NtFrs, DFSR, netlogon, w32Time
    $temp.server = $server
    $temp.KDC = Getservicestatus -service "KDC" -server $server
    $temp.NtFrs = Getservicestatus -service "NtFrs" -server $server
    $temp.DFSR = Getservicestatus -service "DFSR" -server $server
    $temp.netlogon = Getservicestatus -service "netlogon" -server $server
    $temp.w32Time = Getservicestatus -service "w32Time" -server $server
    $report+=$temp
    $b+= $REPORT | select server, KDC, NtFrs, DFSR, netlogon, w32Time | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Service Status</h2>" | Out-String
    #Section - 3
    add-type -AssemblyName microsoft.visualbasic
    $strings = "microsoft.visualbasic.strings" -as [type]
    $report = @()
    foreach ($server in $computername){
    $temp = "" | select server, Netlogon, Advertising, Connectivity, Replication
    $temp.server = $server
    $svt = dcdiag /test:netlogons /s:$server
    $svt1 = dcdiag /test:Advertising /s:$server
    $svt2 = dcdiag /test:connectivity /s:$server
    $svt3 = dcdiag /test:Replications /s:$server
    if($strings::instr($svt, "passed test NetLogons")){$temp.Netlogon = "Passed"}
    else
    {$temp.Netlogon = "Failed"}
    if($strings::instr($svt1, "passed test Advertising")){$temp.Advertising = "Passed"}
    else
    {$temp.Advertising = "Failed"}
    if($strings::instr($svt2, "passed test Connectivity")){$temp.Connectivity = "Passed"}
    else
    {$temp.Connectivity = "Failed"}
    if($strings::instr($svt3, "passed test Replications")){$temp.Replication = "Passed"}
    else
    {$temp.Replication = "Failed"}
    $report+=$temp
    $b+= $REPORT | select server, Netlogon, Advertising, Connectivity, Replication | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>DCDIAG Test</h2>" | Out-String
    #Section - 4
    $workfile = repadmin.exe /showrepl * /csv
    $results = ConvertFrom-Csv -InputObject $workfile | where {$_.'Number of Failures' -ge 1}
    #$results = $results | where {$_.'Number of Failures' -gt 1 }
    if ($results -ne $null ) {
    $results = $results | select "Source DSA", "Naming Context", "Destination DSA" ,"Number of Failures", "Last Failure Time", "Last Success Time", "Last Failure Status"
    $b+= $results | select "Source DSA", "Naming Context", "Destination DSA" ,"Number of Failures", "Last Failure Time", "Last Success Time", "Last Failure Status" | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Replication Status</h2>" | Out-String
    } else {
    $results = "There were no Replication Errors"
    $b+= $results | ConvertTo-HTML -Fragment -PreContent "<h2>Replication Status</h2>" | Out-String
    $head = @'
    <style>
    body { background-color:#dddddd;
    font-family:Tahoma;
    font-size:12pt; }
    td, th { border:1px Solid Black;
    border-collapse:collapse; }
    th { color:white;
    background-color:DarkGoldenRod; }
    table, tr, td, th { padding: 2px; margin: 0px }
    table { margin-left:50px; }
    </style>
    $s = ConvertTo-HTML -head $head -PostContent $b -Body "<h1>Active Directory Checklist</h1>" | Out-string
    $emailFrom = ""
    $emailTo = ""
    $smtpserver= ""
    $smtp=new-object Net.Mail.SmtpClient($smtpServer)
    $msg = new-object Net.Mail.MailMessage
    $msg.From = $emailFrom
    $msg.To.Add($emailTo)
    $msg.IsBodyHTML = $true
    $msg.subject="Active Directory Health Check Report From Dlhdc02"
    $msg.Body = $s
    $smtp.Send($msg)
    Like in the Ping Status (section - 1), I'd like all the cell having text "Not Pinging" should be in RED color.
    Also I am facing an issue in the (Section - 4). When the value of $Results is not null I am getting the desired output but when the value is null the text ""There were no Replication Errors""  is not getting displayed in
    the HTML body. Instead it comes as "*32" (32 is the number of letters in the text).
    Please help me in fixing this ....
    BR
    Himanshu
    MCTS|MCSE|MCSA:Messaging|CCNA

    Here are instructions on  ways to color cells based on content.
    http://tech-comments.blogspot.com/2012/07/powershell-dynamically-color-posh.html
    \_(ツ)_/

  • How to change colors of table col and row header?

    Could I change table header colors when run vi ? Is such a thing possible?
    ex: Header words color from black changed to green in column 2 of table.

    cloud a écrit:
    ...But I mean is "How to change header words color" not changed cell words color.
    tst gave you the answer ! A header cell is just a cell with a -1 value as index...
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Need Help with giving Colors to Table Cells and Table Borders in Dreamweaver CC - Please!

    Hi,
    I am a teacher and use Dreamweaver CC to make my class web page.
    How do I give colors to the cell borders of a table I inserted?  How do I give colors and line thickness
    to table borders, too?
    I bought the David Powers DVD and it doesn't show that.
    Please help.
    Thank you,
    John

    Assuming that you have placed a table in your document and your CSS Designer panel is open
    1. Click the '+' sign
    2. Choose your option. I will choose 'Define in Page'
    3. Follow the above sequence, 1.click on table, 2.ensure table is selected, 3.click on style, 4.click the '+' sign, 5. see the selector appear.
    4. Click on the selector and choose the required Properties.
    You can do the same for the row (<tr>) or a cell (<td>). In fact, this is how you would go about styling anything in your document.

  • How to add button to Table View and initiate action?

    hello,
    i'm new to Javafx 2, i recently followed the tutorial on tableview and would like to add a deletion action on particular row. What i had in mind was to add a delete button on the last column of each row, when clicked it will fire a handler and remove that row from the data observablelist. how do i do that?
    please advice,
    wesley

    Hi,
    Please find the below code. I am creating a table view with two columns. The second column consists of delete button.
    TableVeiw table = new TableView();
    /*First column*/
    final TableColumn<String> titleCol = new TableColumn<String>("Title");
    titleCol.setProperty("title");
    /*Second column*/
    TableColumn<String> actionCol = new TableColumn<String>("Action");
    actionCol.setCellFactory(new Callback<TableColumn<String>, TableCell<String>>() {
          @Override
          public TableCell<String> call(TableColumn<String> param) {
                 final TableCell<String> cell = new TableCell<String>() {
                          @Override
                          public void updateItem(String value, boolean empty) {
                                super.updateItem(value, empty);
                                final VBox vbox = new VBox(5);
                                Image image = new Image(getClass().getResourceAsStream("/images/delete.png"));
                                Button button = new Button("", new ImageView(image));
                                button.getStyleClass().add("deleteButton");
                                final TableCell<String> c = this;
                                button.setOnAction(new EventHandler<ActionEvent>() {
                                      @Override
                                      public void handle(ActionEvent event) {
                                              TableRow tableRow = c.getTableRow();
                                              Item item= (Item) tableRow.getTableView().getItems().get(tableRow.getIndex());
                                              /* TODO : Delete this item from your data list and refresh the table */
                          vbox.getChildren().add(button);
                          setGraphic(vbox);
            cell.setAlignment(Pos.TOP_RIGHT);
            return cell;
    grid.addColumns(titleCol,actionCol);I hope this can help you. :)
    Edited by: Sai Pradeep Dandem on Aug 18, 2011 10:04 PM

  • How to use a checkbox table cell in FXML

    I've figured out how to make a column in a TableView render as a checkbox rather then just text when the UI is written in Java. Now I'm trying to figure out how to do the same thing with FXML. I've tried a couple experiments which have all failed, usually with an exception complaining that it can't coerce a table cell class type (or extension) to an interface (i.e. Callback).
    Right now I'm just trying to make one of the columns be a checkbox. I'm not trying to use any custom type. In other words, in Java I would have done the following:
    TableColumn<MyModel, Boolean> col1 = new TableColumn<MyModel, Boolean>();
    col1.setCellValueFactory(new PropertyValueFactory<MyModel, Boolean>("col1Field"));
    col1.setCellFactory(CheckBoxTableCell.forTableColumn(col1));This works when I build the UI using Java API calls. Does anyone know how to do this in FXML?

    Thank you both.
    I used Luca's suggestion as a first step.
    You'll find attached my v.i. that enables me to do what I wanted. It finally works as I expected. It would have been much simpler if my DAQ was able to measure directly a resistance!
    Loris
    Attachments:
    banc_de_test_température.vi ‏205 KB

  • How to add a new tables in the existing Pricing Report

    Hi,
    I have created Z2 list report in the pricing report (V/LD) with some tables and field names.
    Now I got one requirement that i have to Add some more tables and filed names in the List Report Z2 in the pricing report.
    Could anyone helpme out how can i add tables and fileds names to the existing list report in the Pricing report
    Thanks for your support
    Best Regards
    Amjathpasha

    hi, Pasha:
    May i know how to solve this problem? as i also met this kind of problem.
    and i tried V/lb, do not find the place to add the table.
    Thanks,
    Linda

Maybe you are looking for