【发布时间】:2013-12-05 04:52:29
【问题描述】:
首先是我的代码:
public static Font kingThing;
public static void main(String[] args) throws IOException {
try {
/** Substance look and feel */
UIManager.setLookAndFeel(new NimbusLookAndFeel());
} catch (UnsupportedLookAndFeelException ulafe) {
Loader loader = new Loader();
loader.doFrame();
}
Start Loader = new Start();
Loader.setVisible(true);
DirectBufferHelper.oggstream().connect();
}
public Start() throws IOException {
/** The name of the frame */
super("Client Launcher");
try {
getContentPane().setBackground(Color.BLACK);
setBackground(Color.BLACK);
/** Creates and adds the main configurations of the frame */
BufferedImage image39 = ImageIO.read(getClass().getResourceAsStream("\\jaggl\\igs\\39.png"));
this.setIconImage(image39);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(new Dimension(launcherWidth, launcherHeight));
this.setLocationRelativeTo(null);
this.setResizable(false);
getContentPane().setLayout(null);
paintAll();
} catch (IOException e) {
System.out.println(e);
}
try {
InputStream in = getClass().getResourceAsStream("Kingthings Petrock.ttf");
kingThing = Font.createFont(0, in);
} catch (Throwable e) {
e.printStackTrace();
}
}
&
/**
* Loaders main page Username Display
*/
loggedInAsDisplay = new JLabel(getloggedInAs());
loggedInAsDisplay.setBounds(305, 68, 200, 20);
loggedInAsDisplay.setForeground(Color.LIGHT_GRAY);
loggedInAsDisplay.setFont(kingThing);
getContentPane().add(loggedInAsDisplay);
现在,当我启动框架时,文本显示为一个点。用户名设置为玩家用户名。例如,我登录了我的测试账户和我的主账户。 & 以下显示:
如何让它显示实际文本而不仅仅是一个点。在我添加字体之前,它正确显示了文本。
【问题讨论】:
标签: java swing fonts jlabel nimbus