0

I was wondering how to open two frames using the same code, but work on the code independently. I am making a two players game and I do not want one player's frame to affect the others. I would however like one integer to be shared among them, if not complicated.

Just to make it easier, whenever you start a program twice on java, each window is separate from the other but still uses the same code. I basically want the same thing when I open the programe ONCE, so that they open side by side.

Giacomo
  • 29
  • 5

2 Answers2

0

I am not clear about what you are saying but this is what I understand

  • Need a java program which invokes two different frames and display same integer value

and would do this as follows

  • Create a main class with a static integer declaration
  • Create a class for frame and init the objects that are required and write actions/event listeners for components
  • User integer from main class wherever necessary
  • create objects as part of psvm(String a[]) and initialize the frames
Harshavardhan Konakanchi
  • 4,238
  • 6
  • 36
  • 54
  • Yes. The integer part is not really necessary, as it is just needed to keep track of score. I also already have a class containing the useful code for one player. – Giacomo May 21 '18 at 16:17
0

You can just create 2 objects of this class?

Anestis S.
  • 45
  • 7