swingでGUIを作成すると、各コンポーネントに表示される文字列のフォントはboldで表示されます。あまり見た目がよろしくないので、plainに変える方法を以下に示します。
アプリケーションのエントリポイント(main)のはじめで
UIManager.put("swing.boldMetal", Boolean.FALSE);
としておくと、フォントがplainに変わります。
before

after

サンプルソースコード
import java.awt.*;
import javax.swing.*;
public class FontPlainComponents {
private JFrame jframe;
public FontPlainComponents() {
JFrame jframe = new JFrame();
// メニューバーの生成
JMenuBar jmenubar = new JMenuBar();
// メニューバーにメニューを追加
jmenubar.add(new JMenu("ファイル"));
jmenubar.add(new JMenu("編集"));
// JFrameにメニューバーをセットする
jframe.setJMenuBar(jmenubar);
jframe.setLayout(new GridLayout(5, 3));
// JButtonを15個配置
for (int i = 1; i <= 15; i++) {
jframe.add(new JButton(""+i));
}
jframe.setSize(640, 480);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setVisible(true);
}
/**
* アプリケーションのエントリポイントです。
*/
public static void main(String args[]) {
UIManager.put("swing.boldMetal", Boolean.FALSE);
new FontPlainComponents();
}
}
アプリケーションのエントリポイント(main)のはじめで
UIManager.put("swing.boldMetal", Boolean.FALSE);
としておくと、フォントがplainに変わります。
before

after

サンプルソースコード
import java.awt.*;
import javax.swing.*;
public class FontPlainComponents {
private JFrame jframe;
public FontPlainComponents() {
JFrame jframe = new JFrame();
// メニューバーの生成
JMenuBar jmenubar = new JMenuBar();
// メニューバーにメニューを追加
jmenubar.add(new JMenu("ファイル"));
jmenubar.add(new JMenu("編集"));
// JFrameにメニューバーをセットする
jframe.setJMenuBar(jmenubar);
jframe.setLayout(new GridLayout(5, 3));
// JButtonを15個配置
for (int i = 1; i <= 15; i++) {
jframe.add(new JButton(""+i));
}
jframe.setSize(640, 480);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setVisible(true);
}
/**
* アプリケーションのエントリポイントです。
*/
public static void main(String args[]) {
UIManager.put("swing.boldMetal", Boolean.FALSE);
new FontPlainComponents();
}
}