5 Replies Latest reply on Apr 20, 2011 1:36 AM by EJP

    JTable HTML Font Display Problem with JRE 6U24

      Hello everyone!

      In my JApplet program,I'd like to make the color of one cell of JTable to BLUE.
      Though there has many methods to do it.One method I think easy is to use HTML tag.That is changing the variable like <html><body color='#0000FF'>Value</body></html>

      But it only works well when firstly access the JApplet with JRE 6u24.
      operation as follows:
      1.open the JApplet.You can see the color of cell display BLUE.
      2.on the IE page,refresh the component by pressing F5.You can see the content of the cell which is changed to BLUE is now display as BLANK

      Then I unistall the JRE 6u24 and install JRE of other version.
      The conclusion is that the problem only happens with version after 6U22(including 6U22).It works well with version before 6u21(including 6u21).
      So it seems a bug of JRE of version 6U22.

      Here is my code. Any help would be greatly appreciated!

      html code:
      <APPLET CODE=JTableDemo.class

      java code:

      import java.awt.BorderLayout;
      import java.awt.Container;
      import javax.swing.JApplet;
      import javax.swing.JFrame;
      import javax.swing.JScrollPane;
      import javax.swing.JTable;
      import javax.swing.JTextArea;
      import javax.swing.event.TableModelEvent;
      import javax.swing.event.TableModelListener;
      import javax.swing.table.AbstractTableModel;

      public class JTableDemo extends JApplet {
      private JTextArea txt = new JTextArea(4, 20);

      // The TableModel controls all the data:
      class DataModel extends AbstractTableModel {
       String one = "<html><body color='#0000FF'>one</body></html>"; //change the color to BLUE here ★★★
      Object[][] data = { { one, "two", "three", "four" },
      { "five", "six", "seven", "eight" },
      { "nine", "ten", "eleven", "twelve" }, };

      public int getColumnCount() {
      return data[0].length;

      public int getRowCount() {
      return data.length;

      public Object getValueAt(int row, int col) {
      return data[row][col];

      public void setValueAt(Object val, int row, int col) {
      data[row][col] = val;
      // Indicate the change has happened:

      public void init() {
      Container cp = getContentPane();
      JTable table = new JTable(new DataModel());
      cp.add(new JScrollPane(table));
      cp.add(BorderLayout.SOUTH, txt);

      public static void main(String[] args) {
      run(new JTableDemo(), 350, 200);

      public static void run(JApplet applet, int width, int height) {
      JFrame frame = new JFrame();
      frame.setSize(width, height);

      Edited by: 850469 on 2011-4-7 上午12:36

      Edited by: 850469 on 2011-4-7 上午12:40