TSAssn5.java:197: illegal start of expression
private void clearClientArea(){
^
TSAssn5.java:253: ';' expected
}//end main
^
TSAssn5.java:254: '}' expected
}//end class
^
3 errors
[color=#339999]/* TS NU Grades GUI Interface Assignment 5 */ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; //#1 Implement event proceesing public class TSNUGrades extends JFrame implements ActionListener{ private JTextArea frameTextArea; //create a text area private Container frameContainer; //for the content pane private JScrollPane scrollForTextArea; //scroll bar private BorderLayout frameLayout; //default final int width = 640, height = 480; //Standard size //#2 New attributes for data processing // and status bar private JLabel statusBar; private int addedNumber; private JMenuBar bar; private JMenu fileMenu, editMenu, helpMenu; private JMenuItem exitApp, clearText, displayText, addText, aboutThisApp; // Constructor public TSNUGrades(String title){ //Call to JFrame constructor super(title); //Call initialization init(); } public void init(){ //Use the TSAssn5WindowCloser Class addTSAssn5WindowListener(new TSAssn5WindowCloser(this)); //Set up the Window for the operating system setLookAndFeel(); //Get the content pane frameContainer = getContentPane(); //Create an instance ofa JTextArea frameTextArea = new JTextArea("", 18, 70); frameTextArea.setEditable(true); frameTextArea.setLineWrap(true); //Set the text area in the scroll pane scrollForTextArea = new JScrollPane(frameTextArea); //Create an instance of a border layout frameLayout = new BorderLayout(); frameContainer.setLayout(frameLayout); //#3 Add the status bar (JLabel) frameContainer.add(scrollForTextArea, BorderLayout.CENTER); //create a label to use as a status bar statusBar = new JLabel(" "); frameContainer.add(statusBar, BorderLayout.SOUTH); setSize(height, width); makeMenu(); //#4 Postition the window in the center of the desktop positionWindow(); pack(); setVisible(true); } //----------------------------setLookAndFeel()---------------------- //Set the look and feel for the application public void setLookAndFeel(){ try{ String lookAndFeel = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(lookAndFeel); } catch(Exception lFE){ //process exception } } //3.1 //-----------------------setStatus()--------------------------- private void setStatus(String msg){ statusBar.setText(" " + msg); } //----------------------------positionWindow----------------------------- //#4.1 Position the Frame private void positionWindow(){ Dimension sizeOfScreen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension sizeOfFrame = this.getSize(); if(sizeOfFrame.height > sizeOfScreen.height){ sizeOfFrame.height = sizeOfScreen.height; } if(sizeOfFrame.width > sizeOfScreen.width){ sizeOfFrame.width = sizeOfScreen.width; } this.setLocation( (sizeOfScreen.width - sizeOfFrame.width) /2 , (sizeOfScreen.height - sizeOfFrame.height) /2 ); } //#5----------------------------makeMenu()----------------------------- private void makeMenu(){ //Create a menu bar bar = new JMenuBar(); //create File menu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); //With menu items //generate events and add handlers exitApp = new JMenuItem("Exit"); exitApp.setMnemonic('X'); exitApp.addActionListener(this); //Add the File items to File menu fileMenu.add(exitApp); //create Edit menu editMenu = new JMenu("Edit"); editMenu.setMnemonic('E'); //With menu items clearText = new JMenuItem("Clear Text"); clearText.setMnemonic('R'); displayText = new JMenuItem("Display Text"); displayText.setMnemonic('D'); addText = new JMenuItem("Add Text"); addText.setMnemonic('A'); //Add the Edit items to Edit menu editMenu.add(clearText); clearText.addActionListener(this); editMenu.add(displayText); displayText.addActionListener(this); editMenu.add(addText); addText.addActionListener(this); //create Help menu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); //With menu items aboutThisApp = new JMenuItem("About..."); aboutThisApp.setMnemonic('A'); aboutThisApp.addActionListener(this); //Add the Help items to Help menu helpMenu.add(aboutThisApp); //Add File, Edit, and Help to bar bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); //Add the menu bar to the content pane setJMenuBar(bar); }//end makeMenu //#6 Handle the events the menu generates //-----------------------actionPerformed()------------------------- //#6.1 Use message dialog public void actionPerformed(ActionEvent actionEv){ if(actionEv.getSource() == exitApp){ this.setStatus("Exit"); int flag = JOptionPane.showConfirmDialog( this, "Quit Tiffany Smith's Northwestern grades?", "Exit Tiffany Smith's Northwestern grades", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE ); if(flag == JOptionPane.YES_OPTION){ System.exit(0); } } else if(actionEv.getSource() == clearText){ setStatus("Cleared and score reset"); clearClientArea(); } else if(actionEv.getSource() == aboutThisApp){ setStatus("Tiffany Smith CIS 110"); //#6.2 Use message dialog JOptionPane.showMessageDialog(this, "Tiffany Smith CIS 110", "Tiffany Smith CIS 110", JOptionPane.INFORMATION_MESSAGE); } else if(actionEv.getSource() == displayText){ setStatus("Grades"); clearClientArea(); showCourse(); } else if(actionEv.getSource() == addText){ setStatus("Add Score"); //#6.2 Use input dialog addScore(); } //-------------------------- clearClientArea ()--------------------------- private void clearClientArea(){ frameTextArea.setText(""); resetScore(); } //#6.2.1 //--------------------------addScore()--------------------------- private void addScore(){ try{ String dialogValue = JOptionPane.showInputDialog(this, "Enter final grades:", "Add Score", JOptionPane.INFORMATION_MESSAGE); frameTextArea.append("\n \t" + String.valueOf(dialogValue)); }catch(Exception jEx){ showTestDialog("No value entered.\nEnter integer values."); } } //#6.2.2 //--------------------------showTestDialog()--------------------------- private void showTestDialog(String testItem){ JOptionPane.showMessageDialog(this, testItem); } //#6.2.3 //--------------------------resetScore()--------------------------- private void resetScore(){ addedScore = TBD; } //#7.1-----------------------showCourse()------------------------- private void showCourse(){ //Create a string String CourseGrades = "ENGLISH 205-CN - 25 Intermediate Composition , A- , ORG_BEH 301-CN - 24 Organization behavior , A " + "CIS 110-CN - 16 Introduction to Computer Programming, TBD , ORG_BEH 367-CN - 17 Strategic Planning and Management , TBD , " + "BUS_LAW 201-CN - 14 Business Law I: Contracts and Agency, TBD , POLI_SCI 395-CN - 12 Political Research Seminar: Terrorism, Counterterrorism, and International Security, TBD , "; //Split the string into array elements String coursesAndGrades[] = CourseGrades.split(",\\s"); //Increment by 2's to see both columns //Subtract 1 to allow counting by 2's frameTextArea.append("\n\tCourset\t\tGrades\n"); for(int cntr = 0; cntr < courseAndGrades.length - 1; cntr += 2){ frameTextArea.append("\n\t"); frameTextArea.append(courseAndGrades[cntr] + "\t" + courseAndGrades[cntr+1] ); } } //#3.1-----------------------main()--------------------------------- public static void main(String args[]){ new TSNUGrades("TSNU Grades"); }//end main }//end class