开发者

how change font of all of my components in java

I want to change or modify font of all om my JFrame.

Like just one time I change font and all the frame font size change to new thing.

Previous time I changed look & feel of my window I think that way can, but I am looking for another solution, if any please provide an examp开发者_如何学编程le for me.


One possible solution: execute your code with different VM parameters:

java -Dswing.plaf.metal.controlFont=Tahoma -Dswing.plaf.metal.userFont=Tahoma …


Maybe you can create a config file(or resource file) and when you want to changing something read the file and set values.

resource file:(Of course you can use JSON, XML or anything you want. This is just a example) fontNameA: San Serif fontNameB: XXXX

fontSizeA: 20
fontSizeB: 30

backgourdImage………

class StyleProvider{
  …
  public StyleProvider(String yourConfigFilePath){
    /* read it */
  }
  public String getFontName(/* you can write some arguments here*/){
    return something;
  }
  /* other methods */
}

/* your working code */
StyleProvider sp = new StyleProvider("filepath")
font = new Font(sp.getFontName(), Font.PLAIN, sp.getFontSize());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜