Reputation:
I have used the GUI builder to make some JLabel in a JFrame. These variables are locked and I find it difficult to use them to in another class.
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
public javax.swing.JLabel title;
// End of variables declaration
I had to set the variables public before I could use them in a different class.
Upvotes: 0
Views: 2625
Reputation: 491
You can't set value to the private variables from anotber class. If you want to do so you can pass the variable as the a parameter and set value. Or you have to make JLable public. `
Upvotes: 0
Reputation: 3890
after initComponent()
invoked method in your constructor add for example
jLabel2.setText(test text);
Upvotes: 2
Reputation: 4507
go to the init method and do
title = new JLabel("This is my Title label. No?");
Upvotes: 1