DefaultTableCellRender

this render overload my cpu (%65)
 
class Form08_014_labelRenderer222 extends DefaultTableCellRenderer {
  Form08_014 adaptee;
  public Form08_014_labelRenderer222(Form08_014 adaptee) {
    super();
    this.adaptee = adaptee;
  }

  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    DateFormat formatter;
    switch (column) {
      case 0:
        setHorizontalAlignment(SwingConstants.RIGHT);
        break;
      case 2:
        setHorizontalAlignment(SwingConstants.LEFT);
        break;
      case 1:
      case 4:
/*
        formatter = DateFormat.getDateInstance(DateFormat.SHORT);
        value = (value == null) ? "" : formatter.format(value);
*/
        if (value != null)
          value = DateUtil.tarihIslem((Date) value, 0, this.getLocale());
        setHorizontalAlignment(SwingConstants.CENTER);
        break;
      case 9:
        if ((value != null) && (value != Dil.deger(adaptee.mpGlobal, "REJECTED"))) {
          formatter = DateFormat.getDateInstance(DateFormat.SHORT);
          value = formatter.format(value);
        }
      default:
        setHorizontalAlignment(SwingConstants.CENTER);
    }

    switch (column) {
      case 8:
        if ((value == null) || (value.toString().equals("")) || (value.toString().equals(Dil.deger(adaptee.mpModul, "ACCEPTED")))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setForeground(table.getSelectionForeground());
            setBackground(table.getSelectionBackground());
          } else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
          }
        } else if (value.toString().equals(Dil.deger(adaptee.mpModul, "RISKLI"))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(new Color(192, 192, 0));
            adaptee.sorguTablosu.setSelectionForeground(new Color(0, 0, 0));
          } else {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setBackground(new Color(255, 255, 63));
            setForeground(new Color(63, 63, 63));
          }
        } else if (value.toString().equals(Dil.deger(adaptee.mpModul, "ree"))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(new Color(192, 0, 0));
            adaptee.sorguTablosu.setSelectionForeground(new Color(192, 192, 192));
          } else {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setBackground(new Color(255, 63, 63));
            setForeground(new Color(255, 255, 255));
          }
        }
        break;
      case 9:
        if ((value == null) || (value.toString().equals(""))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setForeground(table.getSelectionForeground());
            setBackground(table.getSelectionBackground());
          } else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
          }
        } else if (value.toString().equals(Dil.deger(adaptee.mpModul, "UYGUNSUZ"))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(new Color(192, 0, 0));
            adaptee.sorguTablosu.setSelectionForeground(new Color(192, 192, 192));
          } else {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setBackground(new Color(255, 63, 63));
            setForeground(new Color(255, 255, 255));
          }
        } else {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(new Color(192, 192, 0));
            adaptee.sorguTablosu.setSelectionForeground(new Color(0, 0, 0));
          } else {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setBackground(new Color(255, 255, 63));
            setForeground(new Color(63, 63, 63));
          }
        }
        break;
      case 14:
      case 15:
        if ((value == null) || (value.toString().equals("")) || (value.toString().equals(Dil.deger(adaptee.mpModul, "NORMAL")))) {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setForeground(table.getSelectionForeground());
            setBackground(table.getSelectionBackground());
          } else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
          }
        } else {
          if (isSelected) {
            adaptee.sorguTablosu.setSelectionBackground(new Color(192, 192, 0));
            adaptee.sorguTablosu.setSelectionForeground(new Color(0, 0, 0));
          } else {
            adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
            adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
            setBackground(new Color(255, 255, 63));
            setForeground(new Color(63, 63, 63));
          }
        }
        break;
      default:
        if (column > 15) {
          if ((value == null) || (value.toString().equals("")) || (value.toString().equals("-"))) {
            if (isSelected) {
              adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
              adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
              setForeground(table.getSelectionForeground());
              setBackground(table.getSelectionBackground());
            } else {
              setForeground(table.getForeground());
              setBackground(table.getBackground());
            }
          } else {
            if (isSelected) {
              adaptee.sorguTablosu.setSelectionBackground(new Color(192, 0, 0));
              adaptee.sorguTablosu.setSelectionForeground(new Color(192, 192, 192));
            } else {
              adaptee.sorguTablosu.setSelectionBackground(EROUtil.getThemeColor(ETable.COLOR_SELBACK));
              adaptee.sorguTablosu.setSelectionForeground(EROUtil.getThemeColor(ETable.COLOR_SELFORE));
              setBackground(new Color(255, 63, 63));
              setForeground(new Color(255, 255, 255));
            }
          }
        }
    }
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  }
}
emrecaniazAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ksivananthCommented:
one classic improvement I can suggest that split this class into multiple renderer class for each columns and so avoid the switch case!

second, you can initialize the formatter once in the constructors and use them in the get... method!

third, value.toString() can be done at once and store in a string var and re-use the string var!

4th, you may want to look at the other your classes used here!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.