Chapter 20 Java Utilities Package and Bit Manipulation (Adelphia web hosting)
Chapter 20 Java Utilities Package and Bit Manipulation 1171 113 // use method getProperty to obtain a property value 114 public void actionPerformed( ActionEvent event ) 115 { 116 Object value = table.getProperty( 117 nameField.getText() ); 118 119 if ( value != null ) 120 showstatus( “Get property: ” + 121 nameField.getText() + ” ” + 122 value.toString() ); 123 124 else 125 showstatus( “Get: ” + nameField.getText() + 126 ” not in table” ); 127 128 listProperties(); 129 } 130 } 131 ); // end call to addActionListener 132 133 southPanel.add( getPropertyButton ); 134 135 // button to contents of Properties table to file 136 JButton saveButton = new JButton( “Save” ); 137 138 saveButton.addActionListener( 139 140 new ActionListener() { 141 142 // use method save to place contents in file 143 public void actionPerformed( ActionEvent event ) 144 { 145 // save contents of table 146 try { 147 FileOutputStream output = 148 new FileOutputStream( “props.dat” ); 149 150 table.store( output, “Sample Properties” ); 151 output.close(); 152 153 listProperties(); 154 } 155 156 // process problems with file output 157 catch( IOException ioException ) { 158 ioException.printStackTrace(); 159 } 160 } 161 } 162 ); // end call to addActionListener 163 164 southPanel.add( saveButton ); 165 Fig. 20.4 Demonstrating class Properties(part 4 of 6).
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services