B
Branko Kaucic
Hi all!
I have a JTable grid, like the one in Java Swing tutorial (see code
below). I created custom cell renderer for cells that contain values of
type Integer, but the text is aligned to te left insted of usual right.
What must I do to align the values on the right.
I used custom rendered, because I need dots in values (for example:
1.000.000).
Ragards,
Branko
--
import javax.swing.table.*;
import java.text.*;
public class MyCellRenderer extends DefaultTableCellRenderer {
private NumberFormat nf;
public MyCellRenderer() { super(); }
public void setValue(Object value) {
if (nf == null)
nf = NumberFormat.getIntegerInstance();
if (value == null)
setText("");
else
setText(nf.format(value));
}
} // end class
--
I have a JTable grid, like the one in Java Swing tutorial (see code
below). I created custom cell renderer for cells that contain values of
type Integer, but the text is aligned to te left insted of usual right.
What must I do to align the values on the right.
I used custom rendered, because I need dots in values (for example:
1.000.000).
Ragards,
Branko
--
import javax.swing.table.*;
import java.text.*;
public class MyCellRenderer extends DefaultTableCellRenderer {
private NumberFormat nf;
public MyCellRenderer() { super(); }
public void setValue(Object value) {
if (nf == null)
nf = NumberFormat.getIntegerInstance();
if (value == null)
setText("");
else
setText(nf.format(value));
}
} // end class
--