Results 1 to 5 of 5
- 08-29-2012, 07:56 AM #1
Member
- Join Date
- Aug 2012
- Posts
- 2
- Rep Power
- 0
- 08-29-2012, 10:02 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: how to embed combobox,checbox in JTable read write to database
That's nice.
What have you managed to do so far?Please do not ask for code as refusal often offends.
- 08-30-2012, 07:44 AM #3
Member
- Join Date
- Aug 2012
- Posts
- 2
- Rep Power
- 0
Re: how to embed combobox,checbox in JTable read write to database
This is the code i am using:
The checkbox is working correctly but the combobox doesn't showDefaultTableModel model = new DefaultTableModel(new String[]{"Name", "Yes or No","AB"}, 0) {
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 1) { //If it is the second column
return Boolean.class;
}
else if (columnIndex == 2) { //If it is the second column
return JComboBox.class;
}else {
return Object.class;
}
}
};
javax.swing.JComboBox box = new JComboBox();
box.removeAllItems();
for (int i=0;i<5;i++){
box.addItem("Name"+(i+1));
}
model.addRow(new Object[]{"1", true,"a"});
model.addRow(new Object[]{"2", false,"a"});
model.addRow(new Object[]{"3", true,"a"});
model.addRow(new Object[]{"4", false,box});
JTable table = new JTable(model);
instead a text is shown in the table's cell "javax.swing.JComboBox[,0,3,195x25,invalid,layout=javax.swing.plaf ......"
- 08-30-2012, 10:36 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: how to embed combobox,checbox in JTable read write to database
Try the first answer here on StackOverflow (but add in generics).
Please do not ask for code as refusal often offends.
- 08-30-2012, 10:52 AM #5
Re: how to embed combobox,checbox in JTable read write to database
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
How to read existing Value from a combobox.
By Khan05 in forum New To JavaReplies: 1Last Post: 09-20-2011, 04:31 PM -
Getting the value from comboBox in Jtable
By skp123 in forum AWT / SwingReplies: 5Last Post: 05-16-2011, 01:45 AM -
Android read/write to database on a web service.
By SeanieSortMeOut in forum AndroidReplies: 1Last Post: 02-05-2011, 01:21 PM -
How to write database queries in Jtable rows and columns?
By Vignesh Karthick in forum AWT / SwingReplies: 1Last Post: 02-02-2011, 03:55 PM -
add combobox for jtable row
By anilkumar_vist in forum Advanced JavaReplies: 1Last Post: 11-18-2009, 11:19 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks