【发布时间】:2018-01-29 04:43:37
【问题描述】:
在高分辨率 4k 屏幕上运行我的 Java 程序时,JFileChooser 中文件夹名称的字体看起来很小,如下所示:
我试图找到一种方法来增加仅在 JFileChooser 中的文件夹/文件名字体大小。我目前的想法是创建一个自定义 JFileChooser,循环其元素并尝试增加文件夹名称的字体。我以为我会增加 FilePane 的字体,但它不起作用。什么都没发生。这是我的代码:
public class JFileChooserCustom extends JFileChooser {
public JFileChooserCustom() {
setFileChooserFont( this.getComponents() );
}
public void setFileChooserFont( Component[] comp ) {
for( int x = 0; x < comp.length; x++ ) {
// System.out.println( comp[x].toString() ); // Trying to know the type of each element in the JFileChooser.
if(comp[x] instanceof Container) setFileChooserFont(((Container)comp[x]).getComponents());
try{
if(comp[x] instanceof FilePane) comp[x].setFont( comp[x].getFont().deriveFont( comp[x].getFont().getSize() * 2f ) );
}
catch(Exception e){}//do nothing
}
}
}
我希望有人可以帮助我。
【问题讨论】:
-
另请参阅 File Browser GUI - 如果您决定放弃
JFileChooser并替换它。 -
@Andrew Thompson ...谢谢,但它似乎非常先进。我不需要这么复杂的选择器:)
标签: java swing font-size jfilechooser