1 19 20 21 package org.netbeans.modules.palette; 22 23 import java.awt.event.ActionEvent ; 24 import javax.swing.AbstractAction ; 25 import javax.swing.ImageIcon ; 26 import org.openide.util.Utilities; 27 import org.openide.ErrorManager; 28 import org.openide.windows.TopComponent; 29 import org.openide.windows.WindowManager; 30 31 32 33 38 public class ShowPaletteAction extends AbstractAction { 39 40 public ShowPaletteAction() { 41 putValue(NAME, Utils.getBundleString("CTL_PaletteAction") ); 42 putValue(SMALL_ICON, new ImageIcon ( 43 Utilities.loadImage("org/netbeans/modules/palette/resources/palette.png"))); } 45 46 47 48 public void actionPerformed(ActionEvent evt) { 49 TopComponent palette = WindowManager.getDefault().findTopComponent("CommonPalette"); if( null == palette ) { 52 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException ( 53 "Can not find CommonPalette component." )); return; 55 } 56 palette.open(); 57 palette.requestActive(); 58 } 59 } 60 61 | Popular Tags |