Alinhar a esquerda uma coluna do JTable

Ôpa,

Como faço para alinhar á esquerda uma coluna do JTable, pois é valor monetário.

é se possivél como faço para fomatar este valor.

Obrigado.

[]…

GuttoSP

Ola,

Vc precisará implementar um TableCellRederer, exemplo:

public class DateCellRenderer
	extends DefaultTableCellRenderer
{
	/** Specifies a format for Date values */
	protected SimpleDateFormat dateFormat;

	/**
	 * Creates a new instance of date cell renderer with default
	 * date format - dd.MM.yyyy HH:mm
	 */
	public DateCellRenderer()
	{
		this("dd.MM.yyyy HH:mm");
	}

	/**
	 * Creates a new instance of date cell renderer with specified
	 * date format.
	 * @param format specifies the date format
	 */
	public DateCellRenderer(String format)
	{
		dateFormat = new SimpleDateFormat(format);
	}

	/**
	 * Returns the table cell renderer. Overrides parent method to format
	 * Double values.
	 *
	 * @param table the JTable to create the Cell renderer for
	 * @param value the value to assign to the cell at [row, column]
	 * @param isSelected true if cell is selected
	 * @param hasFocus true if cell has focus
	 * @param row the row of the cell to render
	 * @param column the column of the cell to render
	 *
	 * @return the default table cell renderer
	 */
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
	    int row, int column)
	{
		super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		setValue((value == null) ? "" : dateFormat.format((Date)value));
		setHorizontalAlignment(SwingConstants.LEFT);

		return this;
	}
}

Formata valores Date. Como essa classe estends JLabel, vc pode indicar o alinhamento pelo método:

setHorizontalAlignment(JLabel.LEFT_ALIGNMENT);

Para usar o renderer:

myTable.setDefaultRenderer(Date.class, new DateCellRenderer);

Mais informações:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender

[]'s

Valeu a dica,

Muito obrigado.

Ps. Meu proximo objetivo e aprender a ler e escrever chines,
contado que eu encontre pessoas como as feras do GUJ.

Valeu

[]…

GuttoSP