How to change font size for strings in 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 in any case I increase the font size from the default size (which I assume is a regular font 11). This brings up another question ... even the font color?

+7
source share
4 answers
 table.setFont(new Font("Serif", Font.BOLD, 20)); 
+28
source

Try to implement your own Custom Renderer , then you can process each line as a JLabel and use setFont (...) accordingly.

+4
source

One option is to set the UIManager hints before initializing the GUI, for example:

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

Use HTML instead of a simple string. Set the font with the tags <font> or <span style = "...">.

http://download.oracle.com/javase/tutorial/uiswing/components/html.html

0
source

All Articles