Hi,
if after entering a name in a cell unsing JTable,
you change the columnWidth:
then the name you entered disappears
Anybody knows how to avoid this?
i suppose its quite simple but i just started learning java
if you want to see the simplified code:
import java.awt.*;
public class DingoMain
{
public DingoMain()
{
DingoMainFrame frame = new DingoMainFrame();
frame.setVisible(true);
}
public static void main(String[] args)
{
new DingoMain();
}
}
------------------------------------------------------------------------------------------------
import java.awt.*;
import javax.swing.*;
public class DingoMainFrame extends JFrame
{
JPanel contentPane;
TablePanel aTPanel= new TablePanel();
public DingoMainFrame()
{
contentPane = (JPanel) this.getContentPane();
this.setSize(new Dimension(474, 343));
contentPane.add(aTPanel);
}
}
------------------------------------------------------------------------------------------------
import java.awt.*;
import javax.swing.*;
public class TablePanel extends JPanel
{
protected JTable table;
private JScrollPane scrollPane;
public final String[] columnNames = {"een", "twee", "drie", "vier",
"vijf"};
String[][] data = new String[5][5];
public TablePanel()
{
table = new JTable(data,columnNames);
scrollPane = new JScrollPane(table);
this.add(scrollPane);
table.setColumnSelectionAllowed(true);
ListSelectionModel colSM =
table.getColumnModel().getSelectionModel();
}
}
ak - 05 Dec 2003 07:07 GMT
> if after entering a name in a cell unsing JTable,
> you change the columnWidth:
> then the name you entered disappears
you have wrong TableModel (immutable).
Try to use DefaultTableModel instead.
____________
http://reader.imagero.com the best java image reader.
Christian Kaufhold - 05 Dec 2003 13:12 GMT
Hello!
> if after entering a name in a cell unsing JTable,
> you change the columnWidth:
> then the name you entered disappears
This is an error in JTable.
See http://www.chka.de/swing/table/FTable.java, method columnMarginChanged
for a fix.
Christian
blabla - 08 Dec 2003 14:56 GMT
> Hello!
>
[quoted text clipped - 6 lines]
> See http://www.chka.de/swing/table/FTable.java, method columnMarginChanged
> for a fix.
It looks very impressing and professional, but being a newie to java i
cant figure out how to use it. i tried changing everywhere JTable into
FTable, but thus the same problem remains, and im afraid i dont know
how to call the specific method in the program.
Christian Kaufhold - 09 Dec 2003 18:28 GMT
>> Hello!
>>
[quoted text clipped - 11 lines]
> FTable, but thus the same problem remains, and im afraid i dont know
> how to call the specific method in the program.
You do not need to call any methods. Just using FTable suffices, in fact
using just the fixed columnMarginChanged implementation without the rest
of FTable suffices.
The example you posted initially works for me then.
Christian

Signature
And in short, I was afraid.
blabla - 15 Dec 2003 16:25 GMT
> You do not need to call any methods. Just using FTable suffices, in fact
> using just the fixed columnMarginChanged implementation without the rest
[quoted text clipped - 3 lines]
>
> Christian
strange things are happening
my comp doesnt want to read the data in FTable(data, columnNames)
i'll wait until a newer version af java overwrites the old bloody JTable
thanks anyway