swing - Java - How can i increase the font of the folder names in JFileChooser? -
when running java program on high resolution 4k screen font of folder names in jfilechooser appear tiny, appear here:
i trying find way increase folder/file name font size in jfilechooser. current idea have create custom jfilechooser, loop on elements , try increase font of folder names. thought i'd increase font of filepane, doesn't work. nothing happens. here code:
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 know type of each element in 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 } } }
i hope assist me this.
don't work filepane, use jlist , jtable instead (these components used filepane present file list).
import java.awt.component; import java.awt.container; import javax.swing.jfilechooser; import javax.swing.jlist; import javax.swing.jtable; import javax.swing.swingutilities; /** * <code>increasefilechooserfont</code>. */ public class increasefilechooserfont { public static void main(string[] args) { swingutilities.invokelater(new runnable() { @override public void run() { jfilechooser chooser = new jfilechooser(); setfilechooserfont(chooser.getcomponents()); chooser.showopendialog(null); system.exit(0); } }); } public static void setfilechooserfont(component[] comp) { (int x = 0; x < comp.length; x++) { // system.out.println( comp[x].tostring() ); // trying know type of each element in jfilechooser. if (comp[x] instanceof container) setfilechooserfont(((container) comp[x]).getcomponents()); try { if (comp[x] instanceof jlist || comp[x] instanceof jtable) comp[x].setfont(comp[x].getfont().derivefont(comp[x].getfont().getsize() * 2f)); } catch (exception e) { } // nothing } } }
Comments
Post a Comment