本帖最后由 于星星 于 2012-7-30 00:23 编辑
报的是new JLabel("haha",JLabel.EAST);参数类型错误。我查了一下jdk文档:
JLabel
public JLabel(String text,
int horizontalAlignment)Creates a JLabel instance with the specified text and horizontal alignment. The label is
centered vertically in its display area.
Parameters:
text - The text to be displayed by the label.
horizontalAlignment - One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
也就是说JLabel的这个构造函数的第二个参数是文本的对齐方式,只有左对齐,居中,右对齐...等方式,而你写的JLabel.EAST,该让它
怎么放文本呢?不正确的参数,它不认识啊,当然会报错了。修改如下图,果断不报错了,哈哈!
|
|