Results 1 to 3 of 3
  1. #1
    snowjo502 is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default 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:
    <HTML><HEAD></HEAD><BODY>
    <APPLET CODE=JTableDemo.class
    MAYSCRIPT
    HEIGHT=150
    WIDTH=200>
    </APPLET></BODY></HTML>

    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:
    fireTableDataChanged();
    }


    }
    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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.getContentPane().add(applet);
    frame.setSize(width, height);
    applet.init();
    applet.start();
    frame.setVisible(true);
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

  3. #3
    snowjo502 is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default JTable HTML Font Display Problem with JRE 6U24

    Any one know why?

Similar Threads

  1. Replies: 1
    Last Post: 12-19-2010, 04:46 AM
  2. Replies: 0
    Last Post: 08-18-2010, 10:31 AM
  3. set different font for each cell in JTable
    By success21061985 in forum AWT / Swing
    Replies: 3
    Last Post: 09-10-2008, 02:06 PM
  4. Replies: 3
    Last Post: 07-06-2008, 12:35 PM
  5. JTable with Font
    By Rama Koti Reddy in forum AWT / Swing
    Replies: 1
    Last Post: 12-12-2007, 05:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •