matthew016
asked on
Add JRadioButtons in a JTable
Hi,
How can I add two JRadioButtons ("Yes" and "No")
in one cell of a JTable,
is this possible ?
Thank you
How can I add two JRadioButtons ("Yes" and "No")
in one cell of a JTable,
is this possible ?
Thank you
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
these are also worth looking at:
http://www.objects.com.au/java/examples/swing/TableCellEditors1.do
http://www.objects.com.au/java/examples/swing/TableCellEditors2.do
http://www.objects.com.au/java/examples/swing/TableCellEditors1.do
http://www.objects.com.au/java/examples/swing/TableCellEditors2.do
ASKER
Thank u,
I have a last question about this,
I'm using a DefaultTableModel because I want to
dynamically add and delete rows.
But some cells may not be edited,
so I read in some tutorials that I need to use an AbstractTableModel and give it in the JTable constructor
and code the isCellEditable function.
But in the JTable constructor I'm already giving the DefaultTableModel as parameter ...
model = new DefaultTableModel(items,co lumnNames( ));
table = new JTable(model);
How disable some cell editing then ?
Thank you.
I have a last question about this,
I'm using a DefaultTableModel because I want to
dynamically add and delete rows.
But some cells may not be edited,
so I read in some tutorials that I need to use an AbstractTableModel and give it in the JTable constructor
and code the isCellEditable function.
But in the JTable constructor I'm already giving the DefaultTableModel as parameter ...
model = new DefaultTableModel(items,co
table = new JTable(model);
How disable some cell editing then ?
Thank you.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
> You need to override isCellEditable
already been mentioned, not sure why you feel you need to repeat comments all the time.
already been mentioned, not sure why you feel you need to repeat comments all the time.
You clearly didn't read matthew016's last question very well. I took the trouble to do so ;-)
thats strange cause u suggested exactly what I said. go figure :-D
>>u suggested exactly what I said
I actually explained what matthew016 already partially knew ;-)
>>so I read in some tutorials that I need to ... code the isCellEditable function.
I actually explained what matthew016 already partially knew ;-)
>>so I read in some tutorials that I need to ... code the isCellEditable function.
ASKER
Stop arguing,
no worries object I can see that u gave tip first,
CEHJ's comment was interessant as well even if I cant use this
JTable table = new JTable(new DefaultTableModel(data, columnNames) {
since I want to add rows dynamically I need the reference of the DefaultModel
no worries object I can see that u gave tip first,
CEHJ's comment was interessant as well even if I cant use this
JTable table = new JTable(new DefaultTableModel(data, columnNames) {
since I want to add rows dynamically I need the reference of the DefaultModel
>>since I want to add rows dynamically I need the reference of the DefaultModel
That's not a problem
DefaultTableModel dtm = new DefaultTableModel(data, columnNames) {
public boolean isCellEditable(int row, int column) {
return column != 0; // First column not editable
}
};
JTable table = new JTable(dtm) ;
That's not a problem
DefaultTableModel dtm = new DefaultTableModel(data, columnNames) {
public boolean isCellEditable(int row, int column) {
return column != 0; // First column not editable
}
};
JTable table = new JTable(dtm) ;
ASKER
ok I did a class MyDefaultTableModel extends DefaultTableModel, it's ok as well,
Well ... then I'll just sh** up :-)
Thx.
Well ... then I'll just sh** up :-)
Thx.
:-)
no worries :)
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
It would be easier to use a JCheckbox