In essence, I want to have my class Game initializing and interacting with classes with the Player Interface implemented.
Now to the issue: When my Game class calls the method getMove from this GUI (code below), the GUI (me) most certainly won't have decided on it's move yet. The Game class will happily wait for the decision, that's not the problem.
I searched for a possibility to kind of stall the function but I haven't found anything nice for that.
What I sort of need is where the function waits until an action from the JFrame occured or likewise a variable has been set to a right amount. The GUI has to work properly during this waiting time.
I found similiar questions like
Java : Wait for user input on swing window
Java Swing: Waiting for Mouse Clicked event before returning an Int
Swing GUI doesn't wait for user input
but I was either not satisfied with the answer or couldn't extract the for me valuable information because the answer was very specific as was the asker. I'm trying to understand as much as I can about Java and OOP but I'm quietly said, still a newbie.
public class GUI extends javax.swing.JFrame implements Player{
/**
* Creates new form GUI
*/
public GUI() {
initComponents();
}
private void initComponents() {...} //not relevant
// Variables declaration - do not modify - not relevant either
private javax.swing.JButton jButton1;
private javax.swing.JLabel jErrorLabel;
private javax.swing.JTable jTable1;
// End of variables declaration
@Override
public int getMove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
EDIT: I want to know how Java handles interfaces with non-java applications, so I imagine a language barrier between the player and the Game which only has the Player as interface, so to say.
I know that his implicates unusual and inefficient code because there is effectively no language barrier. The knowledge is more important than the product for me here.