开发者

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

开发者 https://www.devze.com 2023-03-09 16:42 出处:网络
String columnNames[] = {\"Time\",\"MAP\",\"ICP\",\"CPP\"}; String dataValues[][]= new String [countery]
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

精彩评论

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