Chapter 16 Files and Streams 923 71 72

Chapter 16 Files and Streams 923 71 72 // create and configure button to get 73 // accounts with credit balances 74 zeroButton = new JButton( “Zero balances” ); 75 buttonPanel.add( zeroButton ); 76 zeroButton.addActionListener( new ButtonHandler() ); 77 78 // set up display area 79 recordDisplayArea = new JTextArea(); 80 JScrollPane scroller = 81 new JScrollPane( recordDisplayArea ); 82 83 // attach components to content pane 84 container.add( scroller, BorderLayout.CENTER ); 85 container.add( buttonPanel, BorderLayout.SOUTH ); 86 87 // disable creditButton, debitButton and zeroButton 88 creditButton.setEnabled( false ); 89 debitButton.setEnabled( false ); 90 zeroButton.setEnabled( false ); 91 92 // register window listener 93 addWindowListener( 94 95 // anonymous inner class for windowClosing event 96 new WindowAdapter() { 97 98 // close file and terminate program 99 public void windowClosing( WindowEvent event ) 100 { 101 closeFile(); 102 System.exit( 0 ); 103 } 104 105 } // end anonymous inner class 106 107 ); // end call to addWindowListener 108 109 // pack components and display window 110 pack(); 111 setSize( 600, 250 ); 112 show(); 113 114 } // end CreditInquiry constructor 115 116 // enable user to choose file to open first time; 117 // otherwise, reopen chosen file 118 private void openFile( boolean firstTime ) 119 { 120 if ( firstTime ) { 121 122 // display dialog, so user can choose file 123 JFileChooser fileChooser = new JFileChooser(); Fig. 16.9Credit inquiry program (part 3 of 7). Fig. 16.9
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply