private void addButton(JPanel container, Action action, Hashtable actions, Icon icon) {
   String actionName = (String) action.getValue(Action.NAME);
   String actionCommand = (String) action.getValue(Action.ACTION_COMMAND_KEY);
   JButton button = new JButton(icon);
   button.setActionCommand(actionCommand);
   button.addActionListener(DeepaMehtaClientUtils.getActionByName(actionName, actions));
   container.add(button);
   toolbarButtons[buttonIndex++] = button;
 }
 /**
  * References checked: 8.10.2003 (2.0b2)
  *
  * @param editorType editor type, one of this constants
  *     <UL>
  *       <LI>EDITOR_TYPE_DEFAULT
  *       <LI>EDITOR_TYPE_STYLED
  *       <LI>EDITOR_TYPE_SINGLE_LINE
  *     </UL>
  *
  * @param controler if not <code>null</code> for <code>EDITOR_TYPE_STYLED</code> editors a toolbar
  *     is created
  * @see PresentationDetail#PresentationDetail
  */
 TextEditorPanel(
     int editorType,
     GraphPanelControler controler,
     boolean showToolbar,
     PresentationDetail detail) {
   this.editorType = editorType;
   this.controler = controler;
   this.showToolbar = showToolbar;
   this.detail = detail;
   setLayout(new BorderLayout());
   // --- build this text editor panel ---
   switch (editorType) {
     case EDITOR_TYPE_DEFAULT:
       textComponent = new JTextArea();
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_STYLED:
       textComponent = new JTextPane();
       textComponent.setTransferHandler(new TextTransferHandler()); // ### requires Java 1.4
       // --- add toolbar ---
       if (showToolbar) {
         JPanel bar = new JPanel();
         Hashtable actions = DeepaMehtaClientUtils.createActionTable(textComponent);
         bar.setBackground(COLOR_PROPERTY_PANEL);
         toolbarButtons = new JButton[3];
         addButton(bar, new StyledEditorKit.BoldAction(), actions, controler.boldIcon());
         addButton(bar, new StyledEditorKit.ItalicAction(), actions, controler.italicIcon());
         addButton(bar, new StyledEditorKit.UnderlineAction(), actions, controler.underlineIcon());
         // ### addButton(bar, "H1", CMD_SET_HEADLINE1);
         // ### addButton(bar, "H2", CMD_SET_HEADLINE2);
         add(bar, BorderLayout.SOUTH);
       }
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_SINGLE_LINE:
       textComponent = new JTextField();
       ((JTextField) textComponent).addActionListener(this);
       add(textComponent);
       break;
     default:
       throw new DeepaMehtaException("unexpected text editor type: " + editorType);
   }
   // --- enable automatic drag and drop support ---
   try {
     textComponent.setDragEnabled(true);
   } catch (NoSuchMethodError e) {
     // requires JDK 1.4 ###
   }
 }