Java Reference
In-Depth Information
});
mb . add ( fm );
JMenu vm = mkMenu ( b , "view" );
vm . add ( mi = mkMenuItem ( b , "view" , "tree" ));
vm . add ( mi = mkMenuItem ( b , "view" , "list" ));
vm . add ( mi = mkMenuItem ( b , "view" , "longlist" ));
mb . add ( vm );
JMenu hm = mkMenu ( b , "help" );
hm . add ( mi = mkMenuItem ( b , "help" , "about" ));
// mb.setHelpMenu(hm); // needed for portability (Motif, etc.).
// the main window
JLabel jl = new
new JLabel ( "Menu Demo Window" );
jl . setSize ( 200 , 150 );
cp . add ( jl );
pack ();
}
// Copies of routines that are in darwinsys.jar,
// just here for compilation convenience
/** Convenience routine to make a JMenu */
public
public 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 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 ));
}
Search WWH ::




Custom Search