JTable

Client properties:

Property

Type Notes

Quaqua.Table
.style

java.lang.String Values: "plain", "striped"
 

Client property: Quaqua.Table.style

The Quaqua Look and Feel supports tables with plain style and with striped style (aka alternating row colors).

The picture below shows the two styles as well a table using a large font.

Quaqua Look and Feel - striped JTable
You can specify the desired style by setting the client property Quaqua.Table.style to striped or to plain. If you don't specify a value, the plain style is used.
 

myTable.putClientProperty(

   "Quaqua.Table.style", "striped"

);

 

Avoid Swing's DefaultTableCellEditor

For best results with editable JTable's you may consider using your own implementation of a TableCellEditor, because the default implementation does only draw a focus ring around editable text fields (instead of around all editable components) and it does not properly honour font settings. Please use the following class, as a replacement of the DefaultTableCellEditor. The test package of the Quaqua Look and Feel contains this class as well.
 

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;


public class DefaultCellEditor2 extends DefaultCellEditor {
    
    /**
     * Constructs a DefaultCellEditor that uses a text field.
     *
     * @param textField  a JTextField object
     */
    public DefaultCellEditor2(JTextField textField) {
        super(textField);
        textField.setBorder(new LineBorder(Color.black));
    }
    
    /**
     * Constructs a DefaultCellEditor object that uses 
     * a check box.
     *
     * @param checkBox  a JCheckBox object
     */
    public DefaultCellEditor2(JCheckBox checkBox) {
        super(checkBox);
        checkBox.setBorder(new LineBorder(Color.black));
    }
    
    /**
     * Constructs a DefaultCellEditor object that uses a
     * combo box.
     *
     * @param comboBox  a JComboBox object
     */
    public DefaultCellEditor2(JComboBox comboBox) {
        super(comboBox);
        comboBox.setBorder(new LineBorder(Color.black));
    }
}

 

 

Implementing a TableCellRenderer

If you implement a TableCellRenderer on your own, make sure that the renderer component is non-opaque. If your renderer component is opaque, the component obscurs the stripes of a striped table.