Skip to main content

JXTable/JXTreeTable: improper renderer

3 replies [Last post]
siva
Offline
Joined: 2003-07-15

I was using JXTreeTable and one of my column's class is Long but the data was being displayed right aligned. I initially thought it might be an issue with JXTreeTable but looks like it's base class JXTable also has the same issue.

Below is a test case. If you change "new JXTable" to "new JTable", then it behaves properly.

import javax.swing.table.*;
import javax.swing.*;

import org.jdesktop.swing.*;

public class Test extends AbstractTableModel {

public int getColumnCount() {
return 2;
}

public int getRowCount() {
return 20;
}

public Object getValueAt(int r,int c) {
if(c == 1)
return new Long(c);
return null;
}

public Class getColumnClass(int c) {
if(c == 1) return Long.class;
return String.class;
}

public static void main(String args[]) {
Test test = new Test();
JTable table = new JXTable(test);
JFrame fr = new JFrame();
fr.getContentPane().add(table);
fr.pack();
fr.show();
}
}

So, do I have to set any renderers explicitly for JXTable?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

jdnc-interest@javadesktop.org wrote:

sounds like Issue #134: "JXTable - default renderers not loaded"

>
> So, do I have to set any renderers explicitly for JXTable?

Until the issue is fixed (soon :-), you can patch JXTable code yourself
by changing all internal renderers' visibility to public.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Kleopatra wrote:
>
> Until the issue is fixed (soon :-), you can patch JXTable code yourself
> by changing all internal renderers' visibility to public.
>

Okay, the fix is committed to the cvs. Your code should work now - if
not, please pass me a note.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

siva
Offline
Joined: 2003-07-15

It should be "but the data was being displayed left aligned" in the above note. Not "right aligned".