Pessoal sou novo em java e não estou conseguido fazer algo que creio ser simples
Eu criei um Frame dentro dele coloquei um painel e neste painel coloquei uma Label, e agora eu queria colocar um texto dentro desta Label, a Label foi instanciada em outra crase elas esta como publica mas eu não sei como fazer referência a ela. Alguém poderia me ajudar?
Segue o código que estou tentando usar:
public static void main(String[] args) {
try {
Questao q = lerXml();
new GuiPrincipal().setVisible(true);
lbQuestao.setText(q.getTexto());//AQUI DA ERRO!!!
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
class GuiPrincipal extends JFrame {
public GuiPrincipal (){
setConfig();
}
private void setConfig(){
//Configurações do JFrame:
this.setTitle("Questões");
this.setSize(600,600);//Tamanho Frame
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.getContentPane().setBackground(Color.WHITE);
GuiQuestao jpQuestao = new GuiQuestao();
this.add("Center", jpQuestao);
}
}
class GuiQuestao extends JPanel {
public JLabel lbImagem, lbQuestao;
public GuiQuestao(){
iniciarComponentes();
}
private void iniciarComponentes(){
this.setLayout(new GridLayout(2,1));
lbImagem = new JLabel();
lbQuestao = new JLabel();
this.add(lbImagem);
this.add(lbQuestao);
}
}