904 Files (Web design careers) and Streams Chapter 16 defined at

904 Files and Streams Chapter 16 defined at lines 34 75. Methods getFieldValues (lines 116 124), setField- Values (lines 104 113) and clearFields (lines 96 100) manipulate the text of the JTextFields. Methods getFields (lines 90 93), getDoTask1Button (lines 78 81) and getDoTask2Button(lines 84 87) return individual GUI components, so that a client program can add ActionListeners (for example). 1 // Fig. 16.4: BankUI.java 2 // A reusable GUI for the examples in this chapter. 3 package com.deitel.jhtp4.ch16; 4 5 // Java core packages 6 import java.awt.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class BankUI extends JPanel { 12 13 // label text for GUI 14 protected final static String names[] = { “Account number”, 15 “First name”, “Last name”, “Balance”, 16 “Transaction Amount” }; 17 18 // GUI components; protected for future subclass access 19 protected JLabel labels[]; 20 protected JTextField fields[]; 21 protected JButton doTask1, doTask2; 22 protected JPanel innerPanelCenter, innerPanelSouth; 23 24 // number of text fields in GUI 25 protected int size; 26 27 // constants representing text fields in GUI 28 public static final int ACCOUNT = 0, FIRSTNAME = 1, 29 LASTNAME = 2, BALANCE = 3, TRANSACTION = 4; 30 31 // Set up GUI. Constructor argument of 4 creates four rows 32 // of GUI components. Constructor argument of 5 (used in a 33 // later program) creates five rows of GUI components. 34 public BankUI( int mySize ) 35 { 36 size = mySize; 37 labels = new JLabel[ size ]; 38 fields = new JTextField[ size ]; 39 40 // create labels 41 for ( int count = 0; count < labels.length; count++ ) 42 labels[ count ] = new JLabel( names[ count ] ); 43 44 // create text fields 45 for ( int count = 0; count < fields.length; count++ ) 46 fields[ count ] = new JTextField(); Fig. 16.4 BankUIcontains a reusable GUI for several programs (part 1 of 3).
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply