开发者

How to change the font size for strings in a JTable?

String columnNames[] = {"Time","MAP","ICP","CPP"};
String dataValues[][]= new String [countery]

table = new JTable( dataValues, columnNames );

I am working on a table and storing string values in dataValues. I am curious to know if there is anyway to increase the fon开发者_如何学Got size from the default size (which is I assume regular 11 font). This brings my other question...even font color?


table.setFont(new Font("Serif", Font.BOLD, 20));


Try implementing your own Custom Renderer, then you'll be able to treat each string as a JLabel and use setFont(...) accordingly.


One option is to set UIManager hints before GUI initialization, e.g.:

FontUIResource font = new FontUIResource("Verdana", Font.PLAIN, 24);
UIManager.put("Table.font", font);
UIManager.put("Table.foreground", Color.RED);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜