Final Exam Review Essays

Submitted By Dkk1997YahooCa
Words: 308
Pages: 2

ICS3U Final Exam review : ' )
PrintWriter fileOut = new PrintWriter (new FileWriter ("randNums.txt")); -This is the method of creating another file to outsource data to. -To read the data into the external file use: fileOut.println(data); and at the end of the class put in fileOut.close();
To read in data from a pre-existing data file, use: BufferedReader rF = new BufferedReader (new FileReader ("externalFile.txt"); -To read in data store the data into a variable and then display; data = rF.readLine(); / System.out.println(data);
­­­­­­­­­­­­­­­_______________________________________________________________________________________________­

GUI
CONTENT PANE LAYOUT:
Container contentPane = frame.getContentPane ();------> creates frame layout contentPane.add (topPanel, BorderLayout.PAGE_START);-----> assigns components to top of screen panel.add(btnOne, BorderLayout.LINE_START );-----> assigns components to left, middle of screen contentPane.add (questionPanel, BorderLayout.CENTER);-----> assigns components to the middle of screen contentPane.add (tfPanel, BorderLayout.LINE_END); ----> assigns the components to the middle right section of the screen contentPane.add (btnPanel, BorderLayout.PAGE_END);-----> assigns components to bottom of screen

To create content pane without multiple layouts use:
TOP of code: JPanel panel = new JPanel (); panel.setLayout(new BoxLayout (panel, BoxLayout.PAGE_AXIS));
BOTTOM of code: frame.getContentPane ().add (panel); frame.pack (); frame.setSize (200, 200); frame.setVisible (true);

JTextField()
Creates a textbox for user input
JTextField text1 = new JTextField (15); create textfield 15 characters long
JTextField text2 = new JTextField (“First Name”, 15); places default text
String lastName = text1.getText(); used in the actionPerformed method
JTextField textAge = new JTextField (15); create textbox for numeric entry int age = Integer.parseInt(textAge.getText()); retrieve and parse…