import javax.swing.*; import java.awt.*; public class FrameDemo { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub JFrame frame1 = new YesNoFrame(3,2); frame1.setLocation(0,0); frame1.setSize(300,200); frame1.setTitle("Window 1"); frame1.setVisible(true); JFrame frame2 = new YesNoFrame(3,3); frame2.setLocation(500,500); frame2.setSize(500,300); frame2.setTitle("Window 2"); frame2.setVisible(true); } } class YesNoFrame extends JFrame{ public YesNoFrame(int m, int n){ //super(); this is always called by default: constructs // an instance of the superclass JFrame //don't need to specify "this", but can for clarity //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridLayout layout = new GridLayout(m,n); setLayout(layout); for (int i=0; i