?? svgpopupitem.java
字號:
/* * Created on 20 févr. 2005 ============================================= GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 =============================================GLIPS Graffiti Editor, a SVG EditorCopyright (C) 2003 Jordi SUC, Philippe Gil, SARL ITRISThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAContact : jordi.suc@itris.fr; philippe.gil@itris.fr ============================================= */package fr.itris.glips.svgeditor.menutool;import javax.swing.*;import java.awt.event.*;import java.util.*;import fr.itris.glips.svgeditor.*;import java.awt.*;/** * the class used for creating a pop up item * * @author Jordi SUC */public abstract class SVGPopupItem { /** * the editor */ protected SVGEditor editor; /** * the id of the popup item */ protected String id=""; /** * the menu item */ protected JMenuItem menuItem; /** * the label of the menu item */ protected String label=""; /** * the regular and disabled icons */ protected ImageIcon icon=null, disabledIcon=null; /** * the font */ protected static Font theFont=new Font("theFont", Font.ROMAN_BASELINE, 10); /** * the constructor of the class * @param editor the editor * @param id the id of this popup item * @param label the label for the popup item * @param iconName the name of an icons */ public SVGPopupItem(SVGEditor editor, String id, String label, String iconName){ this.editor=editor; this.id=id; this.label=label; //getting the icons if(iconName!=null){ icon=editor.getResource().getIcon(iconName, false); disabledIcon=editor.getResource().getIcon(iconName, true); } menuItem=new JMenuItem(); menuItem.setText(label); //menuItem.setFont(theFont); if(icon!=null){ menuItem.setIcon(icon); } if(disabledIcon!=null){ menuItem.setDisabledIcon(disabledIcon); } } /** * @return Returns the id. */ public String getId() { return id; } /** * returns the popup item that will be displayed * @param nodes the nodes onto which the popup item will act * @return the menu item */ public JMenuItem getPopupItem(LinkedList nodes){ //the listener the menuitem actions that hides the popup menuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { editor.getPopupManager().hidePopup(); } }); return menuItem; } /** * restores the popup item initial state */ public void setToInitialState(){ ActionListener[] actionListeners=menuItem.getActionListeners(); //removes all the action listeners from the menu item for(int i=0; i<actionListeners.length; i++){ menuItem.removeActionListener(actionListeners[i]); } } /** * @return whether this popup item is enabled or not */ public boolean isEnabled(){ return menuItem.isEnabled(); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -