Results 1 to 2 of 2
  1. #1
    batya is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Unhappy How can I add JCheckBox to each row?

    my code :
    public class JTableTTest {

    public static void main(String[] argv) {

    //data is a list of ambulances
    ArrayList<Ambulance> data=new ArrayList<Ambulance>();
    Ambulance A2 = new Ambulance(13, "צפון",false,"לבן");
    Ambulance A3 = new Ambulance(11, "מרכז",false,"לבן");
    Ambulance A4 = new Ambulance(10, "דרום",false,"לבן");
    Ambulance A5 = new Ambulance(20, "מרכז",false,"לבן");
    data.add( A2);
    data.add(A3);
    data.add(A4);

    Vector rowData = new Vector();
    for(Ambulance a:data)
    {

    Vector ambulance=new Vector
    (Arrays.asList (a.getAmbulanceNumber(),a.getIsInJob(),a.getKindOf Ambulance());
    rowData.add(ambulance);
    }

    String[] columnNames = {"a","b","c","d"};

    Vector columnNamesV = new Vector(Arrays.asList(columnNames));

    JTable table = new JTable(rowData, columnNamesV);
    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Not able to display icon with JCheckBox
    By anindde in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2009, 04:19 AM
  2. JCheckbox in Jtree
    By shajuantony in forum AWT / Swing
    Replies: 10
    Last Post: 09-09-2009, 11:42 AM
  3. How to add JCheckbox as a node in JTree
    By shajuantony in forum New To Java
    Replies: 0
    Last Post: 04-09-2009, 08:19 AM
  4. JCheckBox in JTable column
    By hind in forum New To Java
    Replies: 8
    Last Post: 01-04-2009, 08:40 PM
  5. jcheckbox issues need help. thanks.
    By carlos123 in forum New To Java
    Replies: 3
    Last Post: 11-05-2007, 11:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •