public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Elementary Actor Role")){ ElementaryActorRole currentEAR; int i=0; do{ currentEAR = new ElementaryActorRole(i++); } while(getDiagram().contains(currentEAR)); selectedNode = currentEAR; } else if(e.getActionCommand().equals("Composite Actor Role")){ CompositeActorRole currentCAR; int i=0; do{ currentCAR = new CompositeActorRole(i++); } while(getDiagram().contains(currentCAR)); selectedNode = currentCAR; } else if(e.getActionCommand().equals("Transaction Type")){ TransactionType currentTT; int i=0; do{ currentTT = new TransactionType(i++); } while(getDiagram().contains(currentTT)); selectedNode = currentTT; } else{ super.actionPerformed(e); getLoggerPanel().setText(e.toString()); } } ==== public class MShapesBar extends JToolBar{ private DiagramController controller; public enum DiagramType{ATD, PSD, OFD}; public MShapesBar(){ super("Shapes", JToolBar.VERTICAL); } public void setController(DiagramController controller){ this.controller = controller; } public void load(DiagramType diagramType){ JButton[] buttons = null; Dimension iconsize = new Dimension(30,30); switch(diagramType){ case ATD: buttons = new JButton[]{ //Page 159 new JButton("Boundary of organization"), new JButton("Elementary Actor Role", new ImageIcon(new ElementaryActorRoleImage(new ElementaryActorRole(0,"Example"), iconsize))), new JButton("Composite Actor Role", new ImageIcon(new CompositeActorRoleImage(iconsize, new CompositeActorRole(0,"Example")))), //new JButton("Production Bank"), new JButton("Transaction Type", new ImageIcon(new TransactionTypeImage(new TransactionType(0,"Example"), iconsize))), new JButton("Initiator"), //new JButton("Information"), new JButton("Executor") }; break; } clear(); for(JButton button : buttons){ add(button); //http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html //button.setTransferHandler(new MShapeTransferHandler()); button.addActionListener(controller); //button.addMouseListener(controller); //button.addMouseMotionListener(controller); } public void clear(){ this.removeAll(); } }