Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Table cell renderer

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Table cell renderer

    here is my cell renderer code.I want to add a Jprogressbar in a column and update its value from outside.
    But till now i couldnt update the value of the bar.
    Moreover when i select a row the corresponding Jprogressbar's appearence changes.
    Please help.

    public class tableprogressColumn extends JProgressBar implements TableCellRenderer {
    private JTable table;
    public tableprogressColumn(JTable table,int column,int max) {
    super(0,max);
    setBorderPainted (false);
    setStringPainted (true);
    this.table=table;
    this.setIndeterminate(true);
    TableColumnModel columnModel=table.getColumnModel();
    columnModel.getColumn(column).setCellRenderer(this );
    this.setValue(80);
    this.setForeground(new Color(255,10,10));
    }

    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column) {
    setBackground (table.getBackground ());
    if(value!=null)
    setValue(((Integer)value).intValue());
    return this;
    }

    public boolean isDisplayable() {
    return true;
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Table cell renderer

    I take it from your other thread that you got this figured out on your own?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. set Background Excel cell color using POI API
    By ngamal in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 26th, 2011, 11:20 AM
  2. [SOLVED] find first empty cell?
    By prettynew in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 15th, 2011, 11:52 AM
  3. how to pass value of table cell as parameter/attribute
    By ajincoep in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 8th, 2011, 09:51 AM
  4. Removing the middle cell
    By Shyamz1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 7th, 2010, 01:35 PM
  5. How to create a database in my cell phone?
    By Viggopiano in forum Java ME (Mobile Edition)
    Replies: 2
    Last Post: July 12th, 2010, 07:26 AM