# LaunchBrowserAction.java Sample

This topic inludes the source code for the LaunchBrowserAction.java Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/IdeDevKit/MenuItems/src/ideExtensions/menuItems/

## Sample Source Code

`01 package ideExtensions.menuItems; 02 03 import com.bea.ide.ui.*; 04 import com.bea.ide.actions.DefaultAction; 05 import com.bea.ide.actions.IActionProxy; 06 import com.bea.ide.ui.browser.BrowserSvc; 07 import com.bea.ide.core.MessageSvc; 08 09 import java.awt.event.ActionEvent; 10 import java.net.URL; 11 12 /** 13 * An action to launch a browser with the URL for a "favorite" 14 * in the "Favorites" menu. Along with LaunchBrowserAction1, 15 * LaunchBrowserAction2, and LaunchBrowserAction3, this class 16 * is specified by the extension.xml as the handler for one of the 17 * predefined favorites. See the class FavoritesGenerator for 18 * code that dynamically generates favorites based on user 19 * preferences. 20 */ 21 public class LaunchBrowserAction extends DefaultAction 22 { 23 /** 24 * Launches a browser whose URL is the value specified in the 25 * menu's label. 26 * 27 * @param e The menu click event that occurred in the IDE. 28 */ 29 public void actionPerformed(ActionEvent e) 30 { 31 IActionProxy proxy = getProxy(); 32 try 33 { 34 // Get the value of the URL off the action's label attribute in the extension.xml 35 URL url = new URL((String) proxy.getValue(IActionProxy.PROP_Label)); 36 // Use the browser service to display a browser with the URL. 37 BrowserSvc.get().invokeBrowser(url, true); 38 } catch (Exception ex) 39 { 40 // Display a debugging message in the IDE's Output window. 41 MessageSvc.get().debugLog("Error while displaying favorite: " 42 + ex.getLocalizedMessage()); 43 } 44 } 45 }`