Pages

Get all JFrame in program

Source code below will show you how to get all JFrame that contains in a program

*************************************************************************
COMPLETE SOURCE CODE FOR : GetAllJFrameInAnApplication.java
*************************************************************************


import javax.swing.JFrame;

import java.awt.Frame;

public class GetAllJFrameInAnApplication
{
public static void main(String[]args)
{
//Create JFrame with title ( HAHAHAHA )
JFrame frame1=new JFrame("HAHAHAHA");

//Create JFrame with title ( HEHEHEHE )
JFrame frame2=new JFrame("HEHEHEHE");

//Create JFrame with title ( HUHUHUHU )
JFrame frame3=new JFrame("HUHUHUHU");

//Create JFrame with title ( HIHIHIHI )
JFrame frame4=new JFrame("HIHIHIHI");

//Create JFrame with title ( ZZZZZZZZ )
JFrame frame5=new JFrame("ZZZZZZZZ");

//Create array from type Frame.
//Store all JFrame into this array.
Frame[]allJFrame=Frame.getFrames();

//Print each JFrame title in this application
for(int i=0; i<allJFrame.length; i++)
{
System.out.println("JFrame "+(i+1)+" :"+allJFrame[i].getTitle());
}
}
}


*************************************************************************
JUST COMPILE AND EXECUTE IT
*************************************************************************
Related Posts Plugin for WordPress, Blogger...