How i can change of a row or cell to my jTable?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How i can change of a row or cell to my jTable?

  1. #1
    Dries Guest

    How i can change of a row or cell to my jTable?


    Helppp

    How i can change of a row or cell to my jTable?

    i like to chage the font of a row to the jTable;

    for exmple in this method i can just change the color of a sepecifiek colomn,
    but i can't change the the color of a specifieke row?

    -------------
    public void colorTable(){

    TableColumnModel columnModel = jTable1.getColumnModel();
    //CellEditor celedit = jTable1.getCellEditor(0, 0);
    //TableModel tblcellrender = jTable1.gettgetCellEditor();
    //for(int i=0; i<2; i+=1)
    //{


    columnModel.getColumn(0).setCellRenderer(new DefaultTableCellRenderer()

    {
    public Component getTableCellRendererComponent(JTable table, Object
    value, boolean isSelected, boolean hasFocus, int row, int column)
    {
    Component comp = super.getTableCellRendererComponent(jTable1,
    value,false,false,2,0);


    String optionValue;
    optionValue = jTable1.getValueAt(row, column).toString();
    System.out.println("row is " +row +column+ " " + optionValue);
    //if (optionValue != "")
    if (column == 0)
    {
    System.out.println("grey Blue");
    comp.setForeground(Color.blue); //.setBackground(Color.orange);
    }
    else {
    System.out.println("white color");
    comp.setBackground(Color.white);
    }
    return comp;
    } //end of getTableCellRendererComponent
    });

    //} //end of for
    } //end of colorTable
    -----------
    thanks!!!


  2. #2
    Paul Clapham Guest

    Re: How i can change of a row or cell to my jTable?

    What do you think the "row" parameter is for? (And apply your renderer to
    the entire table, not just to one column.)

    PC2

    Dries <chdries@hotmail.com> wrote in message news:3a6c28a2@news.devx.com...
    >
    > Helppp
    >
    > How i can change of a row or cell to my jTable?
    >
    > i like to chage the font of a row to the jTable;
    >
    > for exmple in this method i can just change the color of a sepecifiek

    colomn,
    > but i can't change the the color of a specifieke row?
    >
    > -------------
    > public void colorTable(){
    >
    > TableColumnModel columnModel = jTable1.getColumnModel();
    > file://CellEditor celedit = jTable1.getCellEditor(0, 0);
    > file://TableModel tblcellrender = jTable1.gettgetCellEditor();
    > file://for(int i=0; i<2; i+=1)
    > file://{
    >
    >
    > columnModel.getColumn(0).setCellRenderer(new

    DefaultTableCellRenderer()
    >
    > {
    > public Component getTableCellRendererComponent(JTable table,

    Object
    > value, boolean isSelected, boolean hasFocus, int row, int column)
    > {
    > Component comp =

    super.getTableCellRendererComponent(jTable1,
    > value,false,false,2,0);
    >
    >
    > String optionValue;
    > optionValue = jTable1.getValueAt(row, column).toString();
    > System.out.println("row is " +row +column+ " " +

    optionValue);
    > file://if (optionValue != "")
    > if (column == 0)
    > {
    > System.out.println("grey Blue");
    > comp.setForeground(Color.blue);

    file://.setBackground(Color.orange);
    > }
    > else {
    > System.out.println("white color");
    > comp.setBackground(Color.white);
    > }
    > return comp;
    > } file://end of getTableCellRendererComponent
    > });
    >
    > file://} file://end of for
    > } file://end of colorTable
    > -----------
    > thanks!!!
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center