我有两个Jframe,其中frame1有一些文本字段,当点击frame1上的一个按钮时,我打开另一个JFrame,其中包含一个搜索框和一个包含搜索结果的JTable.
当我在JTable上单击结果行时,我希望特定值反映在frame1文本字段中.
我尝试将JFrame1的对象作为参数传递,但我对如何实现这一点并不清楚.任何帮助将受到高度赞赏.谢谢
我在同一个包中有两个类.我static variable在一个类中声明了一个并希望在另一个类中访问该变量.
这是我已经声明静态变量的代码
public class wampusGUI extends javax.swing.JFrame {
static String userCommand;
public wampusGUI() {
initComponents();
}
public void setTextArea(String text) {
displayTextArea.append(text);
}
private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) {
userCommand = commandText.getText();
}
public static void main(String args[]) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
wampusGUI w = new wampusGUI();
w.setVisible(true);
Game g = new Game(w);
g.play();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
这是我想要访问变量的代码
public class Game {
private wampusGUI gui;
public …Run Code Online (Sandbox Code Playgroud)