Java Reference
In-Depth Information
/** Convenience routines for internationalized code.
* All methods are static, for ease of use.
*/
public
public class
class I18N
I18N {
/** Convenience routine to make a JButton */
public
public static
static JButton mkButton ( ResourceBundle b , String name ) {
String label ;
try
try { label = b . getString ( name + ".label" ); }
catch
catch ( MissingResourceException e ) { label = name ; }
return
return new
new JButton ( label );
}
/** Convenience routine to make a JMenu */
public
public static
static JMenu mkMenu ( ResourceBundle b , String name ) {
String menuLabel ;
try
try { menuLabel = b . getString ( name + ".label" ); }
catch
catch ( MissingResourceException e ) { menuLabel = name ; }
return
return new
new JMenu ( menuLabel );
}
/** Convenience routine to make a JMenuItem */
public
public static
static JMenuItem mkMenuItem ( ResourceBundle b ,
String menu , String name ) {
String miLabel ;
try
try { miLabel = b . getString ( menu + "." + name + ".label" ); }
catch
catch ( MissingResourceException e ) { miLabel = name ; }
String key = null
null ;
try
try { key = b . getString ( menu + "." + name + ".key" ); }
catch
catch ( MissingResourceException e ) { key = null
null ; }
iif ( key == null
null )
return
return new
new JMenuItem ( miLabel );
else
else
return
return new
new JMenuItem ( miLabel , key . charAt ( 0 ));
}
/** Show a JOptionPane message dialog */
public
public static
void mkDialog ( ResourceBundle b , JFrame parent ,
String dialogTag , String titleTag , int
static void
int messageType ) {
JOptionPane . showMessageDialog (
parent ,
getString ( b , dialogTag , "DIALOG TEXT MISSING: " + dialogTag ),
getString ( b , titleTag , "DIALOG TITLE MISSING: " + titleTag ),
Search WWH ::




Custom Search