FileDocCategorySizeDatePackage
VolumeRenderer.javaAPI DocExample780Mon Nov 09 12:45:50 GMT 1998None

VolumeRenderer.java

// VolumeRenderer.java
// A slider renderer for volume values in a table.
//
import java.awt.Component;
import javax.swing.*;
import javax.swing.table.*;

public class VolumeRenderer extends JScrollBar implements TableCellRenderer {

  public VolumeRenderer() {
    super(JScrollBar.HORIZONTAL);
  }

  public Component getTableCellRendererComponent(JTable table, Object value,
                                                 boolean isSelected,
                                                 boolean hasFocus,
                                                 int row,int column) {
    if (value == null) {
      return this;
    }
    if (value instanceof Volume) {
      setValue(((Volume)value).getVolume());
    }
    else {
      setValue(0);
    }
    return this;
  }
}