我写了一个包含很多类的游戏,它工作得很好。但是每次我想测试一些东西时,从源代码中更改变量的值太累了。所以我研究了如何输入值我没有使用window的变量。我想要的是当我运行程序时,一个面板将被打开,它将询问变量的值。我试图使用JInternal框架,eclipse为你创建一个默认的JInternal框架。 / p>
import java.awt.EventQueue;
import javax.swing.JInternalFrame;
public class Test extends JInternalFrame {
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BoardConstructor frame = new BoardConstructor();
frame.setTitle("Monopoly");
frame.setSize(1500,750);
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.getContentPane().add(new MyShape());
Test frame1 = new Test();
frame1.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Test() {
setBounds(100, 100, 450, 300);
}}
我把我的主要功能写入了这个简单地创建我的游戏。现在我认为应该工作的是这个类应该访问其他类中的变量并改变它们但我不知道它在现实中是如何工作的。我怎么能完成那个?
答案 0 :(得分:0)
如果您在Eclipse中尝试实时调试,那么您可以轻松更改代码中的变量值。如果那不是你要找的东西让我知道