CtlrSttsTableCellRenderer.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.its.cctv.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. cell.setForeground(new Color(0, 0, 0, 255));
  12. if (column == 7) {
  13. String door = table.getModel().getValueAt(row, 7).toString();
  14. if (door.equals("열림")) {
  15. cell.setBackground(new Color(255, 0, 0, 176));
  16. cell.setForeground(new Color(255, 255, 255, 255));
  17. }
  18. }
  19. if (column == 8) {
  20. String fan = table.getModel().getValueAt(row, 8).toString();
  21. if (fan.equals("가동")) {
  22. cell.setBackground(new Color(255, 213, 0, 250));
  23. cell.setForeground(new Color(0, 0, 0, 255));
  24. }
  25. }
  26. if (column == 9) {
  27. String heater = table.getModel().getValueAt(row, 9).toString();
  28. if (heater.equals("가동")) {
  29. cell.setBackground(new Color(255, 213, 0, 250));
  30. cell.setForeground(new Color(0, 0, 0, 255));
  31. }
  32. }
  33. if (column == 11) {
  34. String video = table.getModel().getValueAt(row, 11).toString();
  35. if (video.equals("이상")) {
  36. cell.setBackground(new Color(255, 213, 0, 250));
  37. cell.setForeground(new Color(0, 0, 0, 255));
  38. }
  39. }
  40. } else if (commStts.equals("Login")) {
  41. cell.setBackground(new Color(182, 175, 97, 176));
  42. } else {
  43. cell.setBackground(new Color(182, 97, 97, 176));
  44. }
  45. if (column != 3 && column != 4) {
  46. setHorizontalAlignment(SwingConstants.CENTER);
  47. } else {
  48. setHorizontalAlignment(SwingConstants.LEFT);
  49. }
  50. if (column == 0) {
  51. cell.setBackground(Color.LIGHT_GRAY);
  52. }
  53. return cell;
  54. }
  55. }