この質問の解決策が明白である場合はお詫び申し上げます。解決策は単純であると確信しています。頭の中で正しく理解できないようです。
以下のコードに示すように、JFrameを作成しました。メインメソッド内からラベル(lblStatus)のテキストを変更しようとしていますが、機能しないようです。それらの線に沿ってラベルまたは何かの新しいインスタンスを作成する必要がありますか?
誰かが私にどのようなアプローチを取るべきかについてアドバイスできますか?
よろしく、ダン。
注意-関連するコードを強調するために、いくつかのコンテンツを削除しました。
public class server {
private JFrame frmCorbaServer;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
server window = new server();
window.frmCorbaServer.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
// SERVER CONTENT
// If connection made
System.out.println("Server connected"); // I want this to display in lblStatus!
}
/**
* Create the application.
*/
public server() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmCorbaServer = new JFrame();
frmCorbaServer.setTitle("server 0.1");
frmCorbaServer.setResizable(false);
frmCorbaServer.setBounds(100, 100, 257, 153);
frmCorbaServer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmCorbaServer.getContentPane().setLayout(null);
JLabel lblStatus = new JLabel("...");
lblServant.setFont(new Font("Tahoma", Font.PLAIN, 10));
lblServant.setBounds(10, 36, 231, 14);
frmCorbaServer.getContentPane().add(lblServant);
}
}