import javax.swing.JFrame; import java.util.Scanner; /* Author: James Tam Version: March 22, 2021 Learning objectives: 1) Changing the default behaviour of the close window control of the JFrame. 2) Setting the 4 physical properties of a Java component. 3) Setting the text of the title bar of a JFrame. */ public class Driver { public static void main(String[] args) { String userInput = null; Scanner in = new Scanner(System.in); System.out.print("Type in some text for a title bar of a window: "); userInput = in.nextLine(); JFrame f1 = new JFrame(); JFrame f2 = new JFrame("Hard-code text for title bar"); JFrame f3 = new JFrame(userInput); f1.setBounds(0,0,300,200); f2.setBounds(600,0,640,480); f3.setBounds(800,800,1024,768); f1.setVisible(true); f1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f2.setVisible(true); f2.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); f3.setVisible(true); f3.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); } }