Java Reference
In-Depth Information
private
private String lookupWithDefault ( ResourceBundle rb , String key , String dflt )
{
try
try {
return
return rb . getString ( key );
} catch
catch ( MissingResourceException e ) {
return
return dflt ;
}
}
}
Program: BusCard
This program may seem a bit silly, but it's a good example of configuring a variety of user
interface controls from a resource bundle. The BusCard program allows you to create a digit-
al business card (“interactive business card”) onscreen (see Figure 15-2 ). The labels for all
the GUI controls, and even the pull-down menu options, are loaded from a ResourceBundle .
Figure 15-2. BusCard program in action
Example 15-2 shows the code for the BusCard program.
Example 15-2. BusCard.java
public
public class
class BusCard
BusCard extends
extends JFrame {
private
private static
static final
final long
long serialVersionUID = 1L ;
Search WWH ::




Custom Search