CtlrSttsTableCellRenderer.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.its.vds.ui;
  2. import javax.swing.*;
  3. import javax.swing.table.DefaultTableCellRenderer;
  4. import java.awt.*;
  5. public class CtlrSttsTableCellRenderer extends DefaultTableCellRenderer {
  6. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  7. Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  8. String commStts = table.getModel().getValueAt(row, 6).toString();
  9. if (commStts.equals("Connect")) {
  10. cell.setBackground(new Color(255, 255, 255, 255));
  11. if (column == 7) {
  12. String door = table.getModel().getValueAt(row, 7).toString();
  13. if (door.equals("열림")) {
  14. cell.setBackground(new Color(255, 0, 0, 176));
  15. cell.setForeground(new Color(255, 255, 255, 255));
  16. }
  17. }
  18. if (column == 8) {
  19. String fan = table.getModel().getValueAt(row, 8).toString();
  20. if (fan.equals("가동")) {
  21. cell.setBackground(new Color(255, 213, 0, 250));
  22. cell.setForeground(new Color(0, 0, 0, 255));
  23. }
  24. }
  25. if (column == 9) {
  26. String heater = table.getModel().getValueAt(row, 9).toString();
  27. if (heater.equals("가동")) {
  28. cell.setBackground(new Color(255, 213, 0, 250));
  29. cell.setForeground(new Color(0, 0, 0, 255));
  30. }
  31. }
  32. if (column == 11) {
  33. String video = table.getModel().getValueAt(row, 11).toString();
  34. if (video.equals("이상")) {
  35. cell.setBackground(new Color(255, 213, 0, 250));
  36. cell.setForeground(new Color(0, 0, 0, 255));
  37. }
  38. }
  39. } else if (commStts.equals("Login")) {
  40. cell.setBackground(new Color(182, 175, 97, 176));
  41. } else {
  42. cell.setBackground(new Color(182, 97, 97, 176));
  43. }
  44. if (column != 3 && column != 4) {
  45. setHorizontalAlignment(SwingConstants.CENTER);
  46. } else {
  47. setHorizontalAlignment(SwingConstants.LEFT);
  48. }
  49. if (column == 0) {
  50. cell.setBackground(Color.LIGHT_GRAY);
  51. }
  52. return cell;
  53. }
  54. }