Ask Experts Questions for FREE Help !
Ask
    aaks1962's Avatar
    aaks1962 Posts: 2, Reputation: 1
    New Member
     
    #1

    Jul 18, 2016, 07:23 AM
    Changing cell Color is resetting cell default...
    Hi, I've a JTable and one of the Columns is defined as double, the data inside the cells of that column is aligned Right automatically. When I change the cell color to "red" if the value is less than certain value, then all cells are left aligned!! How can I keep the default settings of the column as it is even after changing the color of the cells? this is the methods I got from some websites on Internet.... public static void setCellRenderer(JTable CustDtlsTbl) { TableCellRenderer cellRenderer = createCellRenderer(); CustDtlsTbl.setDefaultRenderer(Object.class, cellRenderer); } public static TableCellRenderer createCellRenderer() { return new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable CustDtlsTbl, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(CustDtlsTbl, value, isSelected, hasFocus, row, column); if ( column == 3 ){ double newValue = Double.parseDouble(value.toString()); if ( newValue < 100 ){ cell.setForeground(Color.RED); } } else { cell.setForeground(Color.BLACK); } return cell; } }; } Thanks

Check out some similar questions!

Need help on JTable, and change cell color... [ 0 Answers ]

Hi, I got this Method from Internet to change the cell color in JTable, the code changes the whole column color . my question is : how to change the cell color if it has a negative value and leave black if it's positive. here the Method I copied from Internet... public static void...

Eukaryote cell or to a prokaryote cell which of these statements applies [ 4 Answers ]

For each of the descriptions below, decide whether it applies to a eukaryote cell or to a prokaryote cell, or to both. Cell contains mitochondria Cell in which energy for respiration is supplied by ATP Cell contains DNA Cell contains organelles which contain DNA Transcription and...

I want to show in cell the d8 the date which cell a8 hyperlink was last opened [ 2 Answers ]

I have a hyperlink in cell a8. When someone uses this hyperlink I want cell d8 to show the date it was last accessed. In cell e8 I want to show a date two years on from the date in cell d8.

How to is a cell dectected as a infected cell-by virus By the White cells ? [ 2 Answers ]

How to is a cell dectected as a infected cell-by virus By the White cells ?

Cell Border Color Incorrect In FF [ 1 Answers ]

Hi. In internet explorer I get what I want as follows: http://img264.imageshack.us/img264/2254/iepd4.png But in Firefox I get: http://img261.imageshack.us/img261/7241/ffjg5.png


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.