Results 1 to 2 of 2
- 11-04-2009, 08:46 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
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);
}
-
Please read the Sun tutorial on JTable, and you'll learn how to add check boxes to a jtable column. If this is not what you want to do, you may wish to ask a more detailed question.
Similar Threads
-
Not able to display icon with JCheckBox
By anindde in forum AWT / SwingReplies: 2Last Post: 11-01-2009, 03:19 AM -
JCheckbox in Jtree
By shajuantony in forum AWT / SwingReplies: 10Last Post: 09-09-2009, 10:42 AM -
How to add JCheckbox as a node in JTree
By shajuantony in forum javax.swingReplies: 0Last Post: 04-09-2009, 07:19 AM -
JCheckBox in JTable column
By hind in forum New To JavaReplies: 8Last Post: 01-04-2009, 07:40 PM -
jcheckbox issues need help. thanks.
By carlos123 in forum New To JavaReplies: 3Last Post: 11-05-2007, 10:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks