Board index » jbuilder » Adding a TableColumn into a JdbTable

Adding a TableColumn into a JdbTable


2004-06-01 08:17:33 AM
jbuilder21
Before showing my problem, I would like to make a reference to the following
link.
www-106.ibm.com/developerworks/java/library/j-jtable/
I'm trying to implement the association of a CellRenderer and a CellEditor
to a TableColumn, having it with a JComboBox look-like and behavior. The
scenario is as follows:
I have a JdbTable (jdbt_1), which I associate a QueryDataSet (q_1) with. I
created a TableColumn (tc_1) and did set both the CellRenderer and the
CellEditor, and then made the following:
tc_1.setCellRenderer (new cellRenderer()) ; // In the error message,
cellRenderer = jcbx_itemPriceLineRenderer
tc_1.setCellEditor (new cellEditor()) ; // In the error message,
cellEditor = jcbx_itemPriceLineEditor
jdbt_1.addColumn(tc_1) ;
jdbt_1.setCustomColumns(new CustomColumnDescriptor(new int [] {10}, new
TableColumn [] {tc_1})) ;
That means that I'm adding a TableColumn to the jdbt_1, this one already
having the TableColumnModel associated by the q_1 association.
The problem is that the tc_1 is taking the place of the first column of q_1,
even if I change the modelIndex described in the CustomColumnDescriptor's
first parameter. I could place it as -1, 5, 7........ and always takes the
place of that first field of q_1.
Another question is, the dbSwing theory and help in JdbTable's
implementation is not fully clear (at least for me), if you can have a
QueryDataSet associated to a JdbTable and then add one or more TableColumnS
to it (mixed behavior), or just a QueryDataSet associated or just customized
TableColumnS.
Thanks,
Mynor.
 
 

Re:Adding a TableColumn into a JdbTable

Right now, I fixed the problem that I shown below.
My problem now is that every time I change the value of the combobox, I
receive a
java.lang.StackOverflowError. The source error comes from the PostRow
method of the queryDataSet. I guess I have to validate before changing row
in the jdbTable. If anyone has some experience with this, I will appreciate
a lot your help.
Thanks,
Mynor.
"Mynor Paredes" < XXXX@XXXXX.COM >wrote in message
Quote
Before showing my problem, I would like to make a reference to the
following
link.

www-106.ibm.com/developerworks/java/library/j-jtable/

I'm trying to implement the association of a CellRenderer and a CellEditor
to a TableColumn, having it with a JComboBox look-like and behavior. The
scenario is as follows:

I have a JdbTable (jdbt_1), which I associate a QueryDataSet (q_1) with.
I
created a TableColumn (tc_1) and did set both the CellRenderer and the
CellEditor, and then made the following:

tc_1.setCellRenderer (new cellRenderer()) ; // In the error message,
cellRenderer = jcbx_itemPriceLineRenderer
tc_1.setCellEditor (new cellEditor()) ; // In the error
message,
cellEditor = jcbx_itemPriceLineEditor

jdbt_1.addColumn(tc_1) ;
jdbt_1.setCustomColumns(new CustomColumnDescriptor(new int [] {10}, new
TableColumn [] {tc_1})) ;

That means that I'm adding a TableColumn to the jdbt_1, this one already
having the TableColumnModel associated by the q_1 association.

The problem is that the tc_1 is taking the place of the first column of
q_1,
even if I change the modelIndex described in the CustomColumnDescriptor's
first parameter. I could place it as -1, 5, 7........ and always takes
the
place of that first field of q_1.

Another question is, the dbSwing theory and help in JdbTable's
implementation is not fully clear (at least for me), if you can have a
QueryDataSet associated to a JdbTable and then add one or more
TableColumnS
to it (mixed behavior), or just a QueryDataSet associated or just
customized
TableColumnS.

Thanks,
Mynor.


 

Re:Adding a TableColumn into a JdbTable

Hi Mynor,
I'm facing the same problem with custom editors inside JdbTable since I'm
using JBuilderX. The dbSwing deliverd with JBuilder8 did not produce that
problem.
As a work-around, I solved the problem by overriding the stopCellEditing
method in the table cell editor class as shown below. I would appreciate any
information showing how to fix the problem in a clean way however.
private boolean bEditingStopping;
....
....
public boolean stopCellEditing() {
if (!bEditingStopping) {
try {
bEditingStopping = true;
return super.stopCellEditing();
} finally {
bEditingStopping = false;
}
}
return true;
}
Regards
Urs
 

{smallsort}

Re:Adding a TableColumn into a JdbTable

I never use the following phrase, but.......... Oh my god!!! It
worked....... the only cons, is that for example, I display the combobox
when editing, if I change to another row and start editing again, is like
the queryDataSet executes a "refresh", it looses the focus from the cell
that I clicked and refreshes the whole queryDataSet. Any idea?
I really appreciate your help Urs!!! Thanks a LOT!!!!!!!
Best regards,
Mynor.
"Urs Minder" < XXXX@XXXXX.COM >wrote in message
Quote
Hi Mynor,

I'm facing the same problem with custom editors inside JdbTable since I'm
using JBuilderX. The dbSwing deliverd with JBuilder8 did not produce that
problem.

As a work-around, I solved the problem by overriding the stopCellEditing
method in the table cell editor class as shown below. I would appreciate
any
information showing how to fix the problem in a clean way however.

private boolean bEditingStopping;
....
....
public boolean stopCellEditing() {
if (!bEditingStopping) {
try {
bEditingStopping = true;
return super.stopCellEditing();
} finally {
bEditingStopping = false;
}
}
return true;
}

Regards
Urs


 

Re:Adding a TableColumn into a JdbTable

Hi Mynor,
Initially I set the click count in my custom cell editors to be 1. On some
editors, this caused problems similar to the one you are facing now. Try to
use setClickCountToStart(2) as shown in the simple combo box editor below
(you may also have to override the stopCellEditing method as mentioned in my
previous post).
public class ComboTableCellEditor extends DefaultCellEditor {
public ComboTableCellEditor(Object[] values, boolean isNullable) {
super(new JComboBox(values));
setClickCountToStart(2);
}
}
Did you already try out the following direct way?
String[] values = new String[] {"New Delhi", "Canberra", "Rosario"};
queryDataSet.getColumn("MY_COLUMN").setItemEditor(
new DefaultCellEditor(new JComboBox(values )));
I hope this helps!
Regards
Urs
 

Re:Adding a TableColumn into a JdbTable

Thanks a lot Urs, I was having the same Custom Cell Editor problem and I resolved with your suggestion.
thanks again,
Vanitha.
"Urs Minder" < XXXX@XXXXX.COM >wrote:
Quote
Hi Mynor,

Initially I set the click count in my custom cell editors to be 1. On some
editors, this caused problems similar to the one you are facing now. Try to
use setClickCountToStart(2) as shown in the simple combo box editor below
(you may also have to override the stopCellEditing method as mentioned in my
previous post).

public class ComboTableCellEditor extends DefaultCellEditor {
public ComboTableCellEditor(Object[] values, boolean isNullable) {
super(new JComboBox(values));
setClickCountToStart(2);
}
}

Did you already try out the following direct way?

String[] values = new String[] {"New Delhi", "Canberra", "Rosario"};
queryDataSet.getColumn("MY_COLUMN").setItemEditor(
new DefaultCellEditor(new JComboBox(values )));

I hope this helps!

Regards
Urs