我想知道是否可以通过将它们存储到数组或您可能建议的任何方法来生成随机帧。
例如,在我的程序中,我想通过单击按钮随机访问不同的帧,这是我到目前为止的代码。
private void btnNextActionPerformed(java.awt.event.ActionEvent evt){
// Generating a random number from 1 to 25 because I have 25 frames
int min = 1;
int max = 25;
Random rand = new Random();
int randomNum = rand.nextInt(max - min + 1) + ,min;
// I have 25 files with the same name but they end with a different number (from 1 to 25)
String practice = "File" + randomNum
// Opening new frame
// Currently the code below does not work because I think "practice" is seen as a string and so the word is underlined in red
new practice().setVisible(true);
// Closing current frame
this.dipose();
}
我试图将框架/文件/项目存储到一个数组中,然后使用此代码检索它们,但它不起作用。
基本上当用户完成一个问题时,他/她将点击下一个按钮,这将使他/她进入一个新的框架,但我希望随机生成这些框架。