I have a java swing application using JTree.
I recently moved to a UHD monitor, and now the JTree doesn't scale nicely.
I have the feeling it uses the icon to scale the line-height, but have no clue how to influence this myself.
Please be aware that if UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
is being left out, it is unreadably small on the new monitor.
Please see screenshots / simple example code below.
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTree;
import javax.swing.UIManager;
public class JTreeTest extends JFrame
{
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try {
// Set System L&F
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
JTreeTest frame = new JTreeTest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public JTreeTest()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JTree tree = new JTree();
contentPane.add(tree, BorderLayout.CENTER);
}
}
normal resolution jtree screenshot:
UHD resolution jtree screenshot:
Thank you.
Maybe you need to use JTree#setRowHeight(int)