PageRenderTime 38ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. package mpv5.utils.renderer;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import javax.swing.table.*;
  5. /**
  6. * Nobuo Tamemasa (http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html)
  7. * @version 1.0 11/09/98
  8. */
  9. public class ButtonRenderer extends JButton implements TableCellRenderer {
  10. public ButtonRenderer() {
  11. setOpaque(true);
  12. setMargin(new Insets(0,0,0,0));
  13. }
  14. public Component getTableCellRendererComponent(JTable table, Object value,
  15. boolean isSelected, boolean hasFocus, int row, int column) {
  16. if (isSelected) {
  17. setForeground(table.getSelectionForeground());
  18. setBackground(table.getSelectionBackground());
  19. } else{
  20. setForeground(table.getForeground());
  21. setBackground(UIManager.getColor("Button.background"));
  22. }
  23. setText( (value ==null) ? "" : value.toString() );
  24. return this;
  25. }
  26. }