Will new instance of JVM or reflection help in this case

前端 未结 3 1296
无人及你
无人及你 2021-01-14 18:57

I had a problem that I posted before but got no clear solution

How to prevent JFrame from closing.

So I am posting a SSCCE may be this might help in better u

3条回答
  •  耶瑟儿~
    2021-01-14 19:19

    You could use JFrame.getFrames() which returns an array of Frame (you could also getWindows() for a much lower level list of those windows created within the current application context).

    Then, you need to walk through, checking each frame to see if it meets your requirements. After, that, you don't need reflection, you gain direct access to the frames

    The only only way to communicate with other JVM's is via socket comms (such as RMI).

    UPDATE WITH EXAMPLE

    Frame[] listOfFrames = JFrame.getFrames();
    for (Frame : listOfFrames) {
      if (frame instanceof JFrame) {
    
          JFrame aFrame = (JFrame)frame;
    
      }
    }
    

提交回复
热议问题