🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by ftirapelle Tue, 25 May 2004 20:09
JTableHeader why not editable?
#951
Author: ftirapelle
Date: Tue, 25 May 2004 20:09
25 lines
1595 bytes
Why is the JTableHeader not editable. I want to create an editable
JTableHeader but I cannot understand why if I use the
setHeaderRenderer method the header is not editable.
I have seen (http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/editableatomiccontrols/jtable/jtableeditableheader.html)
an example of editable JTableHeader. But why isn't enough the follow
code

....
TableColumnModel colModel = jTable1.getColumnModel();
for (int col = 0; col < jTable1.getColumnCount(); col++)
{
colModel.getColumn(col).setHeaderRenderer(new HeaderFilterRenderer());
}
.....
class HeaderFilterRenderer implements TableCellRenderer
{

public Component getTableCellRendererComponent(JTable table, Object
value,
boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) 
{
return new JTextField ();
}

}
Re: JTableHeader why not editable?
#992
Author: Daniel
Date: Sun, 15 Aug 2004 04:54
45 lines
2860 bytes
hi,

the fact that you are returning the jtextfield as the renderer will not make
the header editable: the framework will just use your control's paint method
to actually render the current header cell and that's it.

for example to have the cell editable, the framework actually gets the edit
field, put it in the appropriate place, make it visible and set the focus to
it. This is the editor, different from the renderer.

This complicated thing is not implemented for the header. If you really want
this you will have to implement it yourself and it will take you some time,
it's quite a challenging stuff...

Daniel

"ftirapelle" <ftirapelle@yahoo.it> wrote in message
news:e16fe653.0405251209.6ca0a1c@posting.google.com...
> Why is the JTableHeader not editable. I want to create an editable
> JTableHeader but I cannot understand why if I use the
> setHeaderRenderer method the header is not editable.
> I have seen
(http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/editableatomiccontrols
/jtable/jtableeditableheader.html)
> an example of editable JTableHeader. But why isn't enough the follow
> code
>
> ....
> TableColumnModel colModel = jTable1.getColumnModel();
> for (int col = 0; col < jTable1.getColumnCount(); col++)
> {
> colModel.getColumn(col).setHeaderRenderer(new HeaderFilterRenderer());
> }
> .....
> class HeaderFilterRenderer implements TableCellRenderer
> {
>
> public Component getTableCellRendererComponent(JTable table, Object
> value,
> boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)
> {
> return new JTextField ();
> }
>
> }
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads