Java Reference
In-Depth Information
private void createElementTypeActions() {
// Other type action definitions...
textAction = new TypeAction("Text", TEXT,'T', CTRL_DOWN_MASK);
// Initialize the array
TypeAction[] actions = {lineAction, rectangleAction, circleAction,
curveAction, textAction};
typeActions = actions;
// Add toolbar icons
// Toolbar icons for existing actions...
textAction.putValue(LARGE_ICON_KEY, TEXT24);
// Add menu item icons
// Menu item icons for existing actions...
textAction.putValue(SMALL_ICON, TEXT16);
// Add tooltip text
// tooltip text for existing actions...
textAction.putValue(SHORT_DESCRIPTION, "Draw text");
}
Directory "Sketcher 4 creating text elements"
You create the Action object for a text element and add values to specify the icons to be used for the
menu item and the toolbar button, plus the tooltip text. The SketcherConstants class needs some addition-
al members to provide for text elements:
package Constants;
import java.awt.*;
import javax.swing.*;
public class SketcherConstants {
// Path for images
public final static String imagePath = "D:/Sketcher/Images/";
// Toolbar icons for File menu items as before...
// Toolbar icons for Type menu items as before...
public final static Icon TEXT24 = new ImageIcon(imagePath + "Text24.gif");
// Toolbar icons for Color menu items as before...
// Icons for the items in the File menu as before...
// Icons for Element menu items as before...
public final static Icon TEXT16 = new ImageIcon(imagePath + Text16.gif");
// Toolbar icons for Color menu items as before...
// Element type definitions
Search WWH ::




Custom Search