JTable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rengaraj
    New Member
    • Jan 2007
    • 168

    #1

    JTable

    Hi dears!
    I have some questions about JTable:
    1- how can set some columns of my table in editable mode and som
    uneditable?

    2- how can I create in some columns controls such as JButton or
    something like link to a file that these address save to my DB?

    3- can I determine # of table rows in run time(when I create my
    JTable)?
    for example to number of records that I retrieve? When I
    create my table rows with Math.random() method in run time, my applet
    works, but when I set this with my number (by Integer.ParseIn t(str))
    it compile successfully but nothing appear! (I get the str from
    servlet that is one number In string format)
    can anybody help me!
    Thanks very much!
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Originally posted by rengaraj
    Hi dears!
    I have some questions about JTable:
    1- how can set some columns of my table in editable mode and som
    uneditable?

    2- how can I create in some columns controls such as JButton or
    something like link to a file that these address save to my DB?

    3- can I determine # of table rows in run time(when I create my
    JTable)?
    for example to number of records that I retrieve? When I
    create my table rows with Math.random() method in run time, my applet
    works, but when I set this with my number (by Integer.ParseIn t(str))
    it compile successfully but nothing appear! (I get the str from
    servlet that is one number In string format)
    can anybody help me!
    Thanks very much!
    1. You can subclass JTable and override isCellEditable

      or you can do something similar with the table model method isCellEditable


      For me the choice is comes down to: is it in the nature of the display that I don't want the user to edit the data (JTable choice) or is it in the nature of the data itself (data model solution).
    2. I don't understand what you are trying to say. Are you talking about changing the column header or changing what is rendered in the table's cells?
    3. Both JTabkle and TableModel have a getRowCount method. Because of filtering, they may return different values. Have you bothered to look up anything in the API? http://java.sun.com/javase/6/docs/api/

    Comment

    Working...