我已经使用 GUI 构建器在 JFrame 中制作了一些 JLabel。这些变量被锁定,我发现很难在另一个类中使用它们。
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
public javax.swing.JLabel title;
// End of variables declaration
我必须先将变量设置为公共(public),然后才能在不同的类中使用它们。
最佳答案
例如在构造函数中调用 initComponent()
方法之后添加
jLabel2.setText(test text);
关于java - 在 Netbeans 中设置 JLabel 文本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43844123/