[ xframe-Bugs-1200208 ] Problem grouping headers
"SourceForge.net" <[email protected]> Wed, 18 May 2005 17:15:29 -0700
| Newsgroups | gmane.text.xml.xframe.xsddoc |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1200208, was opened at 2005-05-12 00:07
Message generated for change (Settings changed) made by kriede
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=454391&aid=1200208&group_id=48863
Category: JXTable
Group: swing
>Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Iñaqui Medina (inaquimj)
>Assigned to: Iñaqui Medina (inaquimj)
>Summary: Problem grouping headers
Initial Comment:
I need to fix an urgent problem and I don't have a clue.
Any ideas?
I was using an old code that is something like:
public class GroupableTableHeader extends
JTableHeader
{
protected Vector columnGroups = null;
public GroupableTableHeader(TableColumnModel
model) {
super(model);
setUI(new GroupableTableHeaderUI());
setReorderingAllowed(false);
setBackground(ECDividerPanel.gContentBgColor);
setForeground(ECPanel.DARK_TEXT_COLOR);
setFont(GUIConstants.standardFont);
}
public void setReorderingAllowed(boolean b) {
reorderingAllowed = false;
}
public void addColumnGroup(ECColumnGroup g) {
if (columnGroups == null) {
columnGroups = new Vector();
}
columnGroups.addElement(g);
}
public Enumeration getColumnGroups(TableColumn
col) {
if (columnGroups == null) return null;
Enumeration enum = columnGroups.elements();
while (enum.hasMoreElements()) {
ColumnGroup cGroup = (ColumnGroup)
enum.nextElement();
Vector v_ret = cGroup.getColumnGroups(col,new
Vector());
if (v_ret != null) {
return v_ret.elements();
}
}
return null;
}
public void setColumnMargin() {
if (columnGroups == null) return;
int columnMargin = getColumnModel
().getColumnMargin();
Enumeration enum = columnGroups.elements();
while (enum.hasMoreElements()) {
ColumnGroup cGroup = (ColumnGroup)
enum.nextElement();
cGroup.setColumnMargin(columnMargin);
}
}
}
I know this is not the best code ever (I didn't write it) but
it used to work and now it doesn't work with JXTables... I
get:
java.lang.NullPointerException
at
net.sf.xframe.swing.table.DefaultColumnGroupHeaderRe
nderer.getTableCellRendererComponent
(DefaultColumnGroupHeaderRenderer.java:52)
at
net.sf.xframe.swing.table.ColumnGroupHeaderUI.paintCe
ll(ColumnGroupHeaderUI.java:118)
at
net.sf.xframe.swing.table.ColumnGroupHeaderUI.paint
(ColumnGroupHeaderUI.java:95)
Anything you can tell me about why this is happening I
would really appreciate it.
----------------------------------------------------------------------
Comment By: Iñaqui Medina (inaquimj)
Date: 2005-05-12 02:29
Message:
Logged In: YES
user_id=1086927
Ok. It seems that getTableHeader().addColumnGroup() works
and I shouldn't be using the code avobe. So I'm changing the
status of this bug to invalid.
I found out 2 things that I'll post separatelly.
----------------------------------------------------------------------
Comment By: Iñaqui Medina (inaquimj)
Date: 2005-05-12 00:57
Message:
Logged In: YES
user_id=1086927
I just tried the the ColumnGroupHeader that comes with
JXTable and still run into:
java.lang.NullPointerException
at
net.sf.xframe.swing.table.DefaultColumnGroupHeaderRenderer
.getTableCellRendererComponent
(DefaultColumnGroupHeaderRenderer.java:52)
Maybe how it's being used is wrong:
final TimeframeCol[] columns = cols;
getLockedTable().setTableHeader(new
ColumnGroupHeader(getLockedTable().getColumnModel())
{
public String getToolTipText(MouseEvent event)
{
int column = getLockedTable
().convertColumnIndexToModel(columnAtPoint(event.getPoint
()));
String toolTip = "";
if(column>-1)
{
try
{
toolTip = columns[column-1].getTooltip();
}
catch (NullPointerException npe)
{
toolTip = "";
}
catch (ArrayIndexOutOfBoundsException
aioobe)
{
toolTip = "";
}
}
return toolTip;
}
});
ColumnGroupHeader header = new ColumnGroupHeader
(getScrollTable().getColumnModel())
{
public String getToolTipText(MouseEvent event)
{
int column = getScrollTable
().convertColumnIndexToModel(columnAtPoint(event.getPoint
()));
String toolTip = "";
if(column>-1)
{
try
{
toolTip = columns
[column+getFrozenColumns()-1].getTooltip();
}
catch (NullPointerException npe)
{
toolTip = "";
}
catch (ArrayIndexOutOfBoundsException
aioobe)
{
toolTip = "";
}
}
return toolTip;
}
};
getScrollTable().setTableHeader(header);
----------------------------------------------------------------------
Comment By: Iñaqui Medina (inaquimj)
Date: 2005-05-12 00:27
Message:
Logged In: YES
user_id=1086927
I just tried the the ColumnGroupHeader that comes with
JXTable and still run into:
java.lang.NullPointerException
at
net.sf.xframe.swing.table.DefaultColumnGroupHeaderRenderer
.getTableCellRendererComponent
(DefaultColumnGroupHeaderRenderer.java:52)
Maybe how it's being used is wrong:
final TimeframeCol[] columns = cols;
getLockedTable().setTableHeader(new
ColumnGroupHeader(getLockedTable().getColumnModel())
{
public String getToolTipText(MouseEvent event)
{
int column = getLockedTable
().convertColumnIndexToModel(columnAtPoint(event.getPoint
()));
String toolTip = "";
if(column>-1)
{
try
{
toolTip = columns[column-1].getTooltip();
}
catch (NullPointerException npe)
{
toolTip = "";
}
catch (ArrayIndexOutOfBoundsException
aioobe)
{
toolTip = "";
}
}
return toolTip;
}
});
ColumnGroupHeader header = new ColumnGroupHeader
(getScrollTable().getColumnModel())
{
public String getToolTipText(MouseEvent event)
{
int column = getScrollTable
().convertColumnIndexToModel(columnAtPoint(event.getPoint
()));
String toolTip = "";
if(column>-1)
{
try
{
toolTip = columns
[column+getFrozenColumns()-1].getTooltip();
}
catch (NullPointerException npe)
{
toolTip = "";
}
catch (ArrayIndexOutOfBoundsException
aioobe)
{
toolTip = "";
}
}
return toolTip;
}
};
getScrollTable().setTableHeader(header);
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=454391&aid=1200208&group_id=48863
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click