KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > diagrams > ToolPalette


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 */

18
19 package org.objectweb.jac.ide.diagrams;
20
21 import CH.ifa.draw.framework.Tool;
22 import CH.ifa.draw.util.PaletteListener;
23 import org.objectweb.jac.aspects.gui.ResourceManager;
24 import java.awt.Point JavaDoc;
25 import javax.swing.JPanel JavaDoc;
26
27
28 public class ToolPalette extends JPanel JavaDoc {
29
30    public ToolPalette() {
31       setLayout(new PaletteLayout(2,new Point JavaDoc(2,2)));
32    }
33
34
35    /**
36     * Add a tool button with the given image, tool, and text
37     *
38     * @param iconName name of the icon of the tool
39     * @param toolName name of the tool
40     * @param tool the tool
41     */

42    public ToolButton addToolButton(PaletteListener paletteListener,
43                                    String JavaDoc iconName, String JavaDoc toolName,
44                                    Tool tool) {
45       ToolButton button =
46          new ToolButton(paletteListener,
47                         ResourceManager.getIconResource(iconName),
48                         toolName,
49                         tool);
50       add(button);
51       return button;
52    }
53
54    ToolButton defaultToolButton;
55    public void setDefaultToolButton(ToolButton defaultToolButton) {
56       this.defaultToolButton = defaultToolButton;
57    }
58    public ToolButton getDefaultToolButton() {
59       return defaultToolButton;
60    }
61 }
62
Popular Tags