非常简单的问题。我的Java AWT(不是Swing)标签根本没有出现。大多数以下代码甚至没有被使用(用于调试此问题)。Java:AWT标签没有出现
只是一个注释:这是在一个框架的构造函数(是的,我已经添加了其他几个面板,并且工作得很好)。其次,框架的布局设置为null
。
我很难过。
File inf = new File("instructions.txt");
Label ilb;
if(inf.exists())
{
Log.v("Loading instructions");
try
{
FileInputStream fis = new FileInputStream(inf);
byte[] insb = new byte[65535];
fis.read(insb);
fis.close();
String inst = new String(insb);
ilb = new Label("test", Label.LEFT);
File fntfile = new File("font/pf_tempesta_seven.ttf");
Font infnt = null;
try {
FileInputStream ffis = new FileInputStream(fntfile);
infnt = Font.createFont(Font.TRUETYPE_FONT, ffis);
ffis.close();
} catch (FontFormatException e) {
Log.e("Could not format LCD font!", e);
} catch (IOException e) {
Log.e("Could not read LCD font file!", e);
}
if(infnt == null)
infnt = new Font("Trebuchet MS", Font.PLAIN, 8);
else
infnt = infnt.deriveFont(8.0f);
//ilb.setFont(infnt);
//ilb.setForeground(new Color(123, 123, 123));
//ilb.setPreferredSize(new Dimension(350, 400));
//ilb.setSize(350, 400);
//ilb.setLocation(580, 190);
Log.d("adding label");
add(ilb);
} catch(IOException e) {
Log.e("Could not read instructions!", e);
}
}else
Log.w("Instructions file not found!");
我以为我在那里有一个关于秋千的评论,但我想我已经离开了它。 **我有AWT的原因。没有摆动** – Qix 2012-03-02 18:25:19
不,这不是一个并发问题。这与它无关。 – Qix 2012-03-02 18:26:43
另外,我更喜欢像我一样对问题进行格式化。为了以防万一,我宁愿让那里的死代码看看是不是另一个我不关注的问题。不管怎么说,还是要谢谢你。 – Qix 2012-03-02 18:27:30