PageRenderTime 432ms CodeModel.GetById 247ms app.highlight 3ms RepoModel.GetById 180ms app.codeStats 0ms

/src/mpv5/utils/renderer/ButtonRenderer.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 31 lines | 22 code | 5 blank | 4 comment | 1 complexity | befa7a0fd258b97732963c6de4a1e7da MD5 | raw file
 1
 2package mpv5.utils.renderer;
 3
 4import java.awt.*;
 5import javax.swing.*;
 6import javax.swing.table.*;
 7
 8/**
 9 * Nobuo Tamemasa (http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html)
10 * @version 1.0 11/09/98
11 */
12public class ButtonRenderer extends JButton implements TableCellRenderer {
13
14  public ButtonRenderer() {
15    setOpaque(true);
16    setMargin(new Insets(0,0,0,0));
17  }
18
19  public Component getTableCellRendererComponent(JTable table, Object value,
20                   boolean isSelected, boolean hasFocus, int row, int column) {
21    if (isSelected) {
22      setForeground(table.getSelectionForeground());
23      setBackground(table.getSelectionBackground());
24    } else{
25      setForeground(table.getForeground());
26      setBackground(UIManager.getColor("Button.background"));
27    }
28    setText( (value ==null) ? "" : value.toString() );
29    return this;
30  }
31}