Example #1
0
  private void listPeople() {

    try {

      jScrollPane1.getViewport().setView(null);

      JFlowPanel jPeople = new JFlowPanel();
      jPeople.applyComponentOrientation(getComponentOrientation());

      java.util.List people = m_dlSystem.listPeopleVisible();

      for (int i = 0; i < people.size(); i++) {

        AppUser user = (AppUser) people.get(i);

        JButton btn = new JButton(new AppUserAction(user));
        btn.applyComponentOrientation(getComponentOrientation());
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setMaximumSize(new Dimension(150, 50));
        btn.setPreferredSize(new Dimension(150, 50));
        btn.setMinimumSize(new Dimension(150, 50));

        jPeople.add(btn);
      }
      jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
      ee.printStackTrace();
    }
  }
Example #2
0
  /**
   * Create a button to go inside of the toolbar. By default this will load an image resource. The
   * image filename is relative to the classpath (including the '.' directory if its a part of the
   * classpath), and may either be in a JAR file or a separate file.
   *
   * @param key The key in the resource file to serve as the basis of lookups.
   */
  protected JButton createToolbarButton(String key) {
    URL url = getResource(key + imageSuffix);
    JButton b =
        new JButton(new ImageIcon(url)) {

          @Override
          public float getAlignmentY() {
            return 0.5f;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setMargin(new Insets(1, 1, 1, 1));

    String astr = getProperty(key + actionSuffix);
    if (astr == null) {
      astr = key;
    }
    Action a = getAction(astr);
    if (a != null) {
      b.setActionCommand(astr);
      b.addActionListener(a);
    } else {
      b.setEnabled(false);
    }

    String tip = getResourceString(key + tipSuffix);
    if (tip != null) {
      b.setToolTipText(tip);
    }

    return b;
  }
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
  private JToolBar makeToolBar() {
    JToolBar tool = new JToolBar();
    tool.setFloatable(false);

    // Setup the buttons
    save.setRequestFocusEnabled(false);
    tool.add(save);
    tool.addSeparator();

    loadFile = new JButton(LGM.getIconForKey("Toolbar.OPEN")); // $NON-NLS-1$
    loadFile.setToolTipText(Messages.getString("EnigmaSettingsFrame.LOAD_TIP")); // $NON-NLS-1$
    loadFile.setRequestFocusEnabled(false);
    loadFile.addActionListener(this);
    tool.add(loadFile);
    saveFile = new JButton(LGM.getIconForKey("Toolbar.SAVEAS")); // $NON-NLS-1$
    saveFile.setToolTipText(Messages.getString("EnigmaSettingsFrame.SAVE_TIP")); // $NON-NLS-1$
    saveFile.setRequestFocusEnabled(false);
    saveFile.addActionListener(this);
    tool.add(saveFile);

    tool.addSeparator();
    return tool;
  }
Example #5
0
  /**
   * Add an action to the toolbar. If the tool tip is null, use the "tooltip" property already in
   * the action, otherwise add the property to the action. The new button is added to the action as
   * the "toolButton" property. If either an icon or a text string are specified (non-null), they
   * are added.
   */
  public static JButton addToolBarButton(
      JToolBar toolbar, Action action, String tooltip, Icon icon, String lbl, boolean isEnabled) {
    if (tooltip == null) {
      tooltip = (String) action.getValue("tooltip");
    } else {
      action.putValue("tooltip", tooltip);
    }

    JButton button = toolbar.add(action);
    button.setToolTipText(tooltip);
    button.setText(null);
    button.setRequestFocusEnabled(false);

    if (icon != null) {
      button.setIcon(icon);
    }

    if (lbl != null) {
      button.setText(lbl);
    }

    Icon rolloverIcon = (Icon) action.getValue(ROLLOVER_ICON);
    if (rolloverIcon != null) {
      button.setRolloverIcon(rolloverIcon);
    }
    Icon rolloverSelectedIcon = (Icon) action.getValue(ROLLOVER_SELECTED_ICON);
    if (rolloverSelectedIcon != null) {
      button.setRolloverSelectedIcon(rolloverSelectedIcon);
    }
    Icon selectedIcon = (Icon) action.getValue(SELECTED_ICON);
    if (selectedIcon != null) {
      button.setSelectedIcon(selectedIcon);
    }

    button.setMargin(new Insets(0, 0, 0, 0));

    //        button.setBorderPainted(false);
    button.setBorderPainted(true);
    button.setEnabled(isEnabled);
    action.putValue("toolBarButton", button);
    return button;
  }
Example #6
0
    private JTextField addField(JPanel directoryPanel, String label, String defaultText) {
      JTextField field = new JTextField(defaultText);

      directoryPanel.add(new JLabel(label, SwingConstants.RIGHT));

      Box fieldBox = new Box(BoxLayout.Y_AXIS);
      fieldBox.add(Box.createGlue());
      Dimension dim = field.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      field.setMaximumSize(dim);
      fieldBox.add(field);
      fieldBox.add(Box.createGlue());
      directoryPanel.add(fieldBox);
      JButton choose = new JButton("Choose...");
      choose.setRequestFocusEnabled(false);
      choose.addActionListener(new ActionHandler(field));
      directoryPanel.add(choose);

      return field;
    }
  /**
   * Creates and return an instance of JButton that can be used to collapse the right component in
   * the metal split pane.
   */
  protected JButton createRightOneTouchButton() {
    JButton b =
        new JButton() {
          // Sprite buffer for the arrow image of the right button
          int[][] buffer = {
            {2, 2, 2, 2, 2, 2, 2, 2},
            {0, 1, 1, 1, 1, 1, 1, 3},
            {0, 0, 1, 1, 1, 1, 3, 0},
            {0, 0, 0, 1, 1, 3, 0, 0},
            {0, 0, 0, 0, 3, 0, 0, 0}
          };

          public void setBorder(Border border) {}

          public void paint(Graphics g) {
            JSplitPane splitPane = getSplitPaneFromSuper();
            if (splitPane != null) {
              int oneTouchSize = getOneTouchSizeFromSuper();
              int orientation = getOrientationFromSuper();
              int blockSize = Math.min(getDividerSize(), oneTouchSize);

              // Initialize the color array
              Color[] colors = {
                this.getBackground(),
                MetalLookAndFeel.getPrimaryControlDarkShadow(),
                MetalLookAndFeel.getPrimaryControlInfo(),
                MetalLookAndFeel.getPrimaryControlHighlight()
              };

              // Fill the background first ...
              g.setColor(this.getBackground());
              if (isOpaque()) {
                g.fillRect(0, 0, this.getWidth(), this.getHeight());
              }

              // ... then draw the arrow.
              if (getModel().isPressed()) {
                // Adjust color mapping for pressed button state
                colors[1] = colors[2];
              }
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
                // Draw the image for a vertical split
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      continue;
                    } else {
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    g.drawLine(i, j, i, j);
                  }
                }
              } else {
                // Draw the image for a horizontal split
                // by simply swaping the i and j axis.
                // Except the drawLine() call this code is
                // identical to the code block above. This was done
                // in order to remove the additional orientation
                // check for each pixel.
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      // Nothing needs
                      // to be drawn
                      continue;
                    } else {
                      // Set the color from the
                      // color map
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    // Draw a pixel
                    g.drawLine(j, i, j, i);
                  }
                }
              }
            }
          }

          // Don't want the button to participate in focus traversable.
          public boolean isFocusTraversable() {
            return false;
          }
        };
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    maybeMakeButtonOpaque(b);
    return b;
  }
  private JToolBar makeToolBar() {
    JToolBar tool = new JToolBar();
    tool.setFloatable(false);

    // Setup the buttons
    save.setRequestFocusEnabled(false);
    tool.add(save);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    tool.addSeparator();
    cbFonts = new JComboBox(fontNames);
    cbFonts.setRequestFocusEnabled(false);
    cbFonts.setMaximumSize(cbFonts.getPreferredSize());
    cbFonts.setEditable(true);
    ActionListener lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (fFamilyChange) {
              fFamilyChange = false;
              return;
            }
            editor.grabFocus();
            setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString());
          }
        };

    cbFonts.addActionListener(lst);
    tool.add(cbFonts);
    tool.addSeparator();
    sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1));
    sSizes.setRequestFocusEnabled(false);
    sSizes.setMaximumSize(sSizes.getPreferredSize());
    sSizes.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            if (fSizeChange) {
              fSizeChange = false;
              return;
            }
            setSelectionAttribute(StyleConstants.Size, sSizes.getValue());
            editor.grabFocus();
          }
        });
    tool.add(sSizes);
    tool.addSeparator();

    tbBold = new JToggleButton(LGM.getIconForKey("GameInformationFrame.BOLD")); // $NON-NLS-1$
    tbBold.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Bold, tbBold.isSelected());
          }
        };
    tbBold.addActionListener(lst);
    tool.add(tbBold);
    tbItalic = new JToggleButton(LGM.getIconForKey("GameInformationFrame.ITALIC")); // $NON-NLS-1$
    tbItalic.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Italic, tbItalic.isSelected());
          }
        };
    tbItalic.addActionListener(lst);
    tool.add(tbItalic);
    tbUnderline =
        new JToggleButton(LGM.getIconForKey("GameInformationFrame.UNDERLINED")); // $NON-NLS-1$
    tbUnderline.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Underline, tbUnderline.isSelected());
          }
        };
    tbUnderline.addActionListener(lst);
    tool.add(tbUnderline);

    tool.addSeparator();
    JButton butFontColor =
        new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    butFontColor.setRequestFocusEnabled(false);
    butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    butFontColor.addActionListener(this);
    tool.add(butFontColor);
    JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$
    but.setRequestFocusEnabled(false);
    but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$
    but.addActionListener(this);
    tool.add(but);
    return tool;
  }
  void jbInit() throws Exception {

    if (!Configuration.get("DISABLE_L10N").equals("yes"))
      net.sf.memoranda.ui.htmleditor.util.Local.setMessages(Local.getMessages());

    editor = new HTMLEditor();

    this.setLayout(borderLayout1);

    btn_New_Note.setAction(newAction);
    btn_New_Note.setMaximumSize(new Dimension(24, 24));
    btn_New_Note.setMinimumSize(new Dimension(24, 24));
    btn_New_Note.setPreferredSize(new Dimension(24, 24));
    btn_New_Note.setRequestFocusEnabled(false);
    btn_New_Note.setToolTipText(Local.getString("New note"));
    btn_New_Note.setBorderPainted(false);
    btn_New_Note.setFocusable(false);
    btn_New_Note.setText("");

    importB.setAction(importAction);
    importB.setBorderPainted(false);
    importB.setFocusable(false);
    importB.setPreferredSize(new Dimension(24, 24));
    importB.setRequestFocusEnabled(false);
    importB.setToolTipText(Local.getString("Insert file"));
    importB.setMinimumSize(new Dimension(24, 24));
    importB.setMaximumSize(new Dimension(24, 24));
    importB.setText("");

    exportB.setAction(exportAction);
    exportB.setMaximumSize(new Dimension(24, 24));
    exportB.setMinimumSize(new Dimension(24, 24));
    exportB.setPreferredSize(new Dimension(24, 24));
    exportB.setRequestFocusEnabled(false);
    exportB.setToolTipText(Local.getString("Export note to file"));
    exportB.setBorderPainted(false);
    exportB.setFocusable(false);
    exportB.setText("");

    redoB.setAction(editor.redoAction);
    redoB.setMaximumSize(new Dimension(24, 24));
    redoB.setMinimumSize(new Dimension(24, 24));
    redoB.setPreferredSize(new Dimension(24, 24));
    redoB.setRequestFocusEnabled(false);
    redoB.setToolTipText(Local.getString("Redo"));
    redoB.setBorderPainted(false);
    redoB.setFocusable(false);
    redoB.setText("");

    copyB.setAction(editor.copyAction);
    copyB.setMaximumSize(new Dimension(24, 24));
    copyB.setMinimumSize(new Dimension(24, 24));
    copyB.setPreferredSize(new Dimension(24, 24));
    copyB.setRequestFocusEnabled(false);
    copyB.setToolTipText(Local.getString("Copy"));
    copyB.setBorderPainted(false);
    copyB.setFocusable(false);
    copyB.setText("");

    historyBackB.setAction(History.historyBackAction);
    historyBackB.setMaximumSize(new Dimension(24, 24));
    historyBackB.setMinimumSize(new Dimension(24, 24));
    historyBackB.setPreferredSize(new Dimension(24, 24));
    historyBackB.setRequestFocusEnabled(false);
    historyBackB.setToolTipText(Local.getString("History back"));
    historyBackB.setBorderPainted(false);
    historyBackB.setFocusable(false);
    historyBackB.setText("");

    historyForwardB.setAction(History.historyForwardAction);
    historyForwardB.setBorderPainted(false);
    historyForwardB.setFocusable(false);
    historyForwardB.setPreferredSize(new Dimension(24, 24));
    historyForwardB.setRequestFocusEnabled(false);
    historyForwardB.setToolTipText(Local.getString("History forward"));
    historyForwardB.setMinimumSize(new Dimension(24, 24));
    historyForwardB.setMaximumSize(new Dimension(24, 24));
    historyForwardB.setText("");

    pasteB.setAction(editor.pasteAction);
    pasteB.setMaximumSize(new Dimension(24, 24));
    pasteB.setMinimumSize(new Dimension(24, 24));
    pasteB.setPreferredSize(new Dimension(24, 24));
    pasteB.setRequestFocusEnabled(false);
    pasteB.setToolTipText(Local.getString("paste"));
    pasteB.setBorderPainted(false);
    pasteB.setFocusable(false);
    pasteB.setText("");

    insDateB.setAction(insertDateAction);
    insDateB.setBorderPainted(false);
    insDateB.setFocusable(false);
    insDateB.setPreferredSize(new Dimension(24, 24));
    insDateB.setRequestFocusEnabled(false);
    insDateB.setToolTipText(Local.getString("Insert current date"));
    insDateB.setMinimumSize(new Dimension(24, 24));
    insDateB.setMaximumSize(new Dimension(24, 24));
    insDateB.setText("");

    insTimeB.setAction(insertTimeAction);
    insTimeB.setMaximumSize(new Dimension(24, 24));
    insTimeB.setMinimumSize(new Dimension(24, 24));
    insTimeB.setPreferredSize(new Dimension(24, 24));
    insTimeB.setRequestFocusEnabled(false);
    insTimeB.setToolTipText(Local.getString("Insert current time"));
    insTimeB.setBorderPainted(false);
    insTimeB.setFocusable(false);
    insTimeB.setText("");

    undoB.setAction(editor.undoAction);
    undoB.setBorderPainted(false);
    undoB.setFocusable(false);
    undoB.setPreferredSize(new Dimension(24, 24));
    undoB.setRequestFocusEnabled(false);
    undoB.setToolTipText(Local.getString("Undo"));
    undoB.setMinimumSize(new Dimension(24, 24));
    undoB.setMaximumSize(new Dimension(24, 24));
    undoB.setText("");

    cutB.setAction(editor.cutAction);
    cutB.setBorderPainted(false);
    cutB.setFocusable(false);
    cutB.setPreferredSize(new Dimension(24, 24));
    cutB.setRequestFocusEnabled(false);
    cutB.setToolTipText(Local.getString("Cut"));
    cutB.setMinimumSize(new Dimension(24, 24));
    cutB.setMaximumSize(new Dimension(24, 24));
    cutB.setText("");

    previewB.setAction(previewAction);
    previewB.setBorderPainted(false);
    previewB.setFocusable(false);
    previewB.setPreferredSize(new Dimension(24, 24));
    previewB.setRequestFocusEnabled(false);
    previewB.setToolTipText(previewAction.getValue(Action.NAME).toString());
    previewB.setMinimumSize(new Dimension(24, 24));
    previewB.setMaximumSize(new Dimension(24, 24));
    previewB.setText("");

    /*
     * printB.setAction(printAction); printB.setMaximumSize(new
     * Dimension(24, 24)); printB.setMinimumSize(new Dimension(24, 24));
     * printB.setPreferredSize(new Dimension(24, 24));
     * printB.setRequestFocusEnabled(false);
     * printB.setToolTipText(Local.getString("Print"));
     * printB.setBorderPainted(false); printB.setFocusable(false);
     * printB.setText("");
     */

    jPanel1.setLayout(borderLayout2);
    titleLabel.setFont(new java.awt.Font("Dialog", 1, 10));
    titleLabel.setText(Local.getString("Title") + "  ");
    titleField.setText("");
    editorToolBar.setFloatable(false);
    editor.editToolbar.setFloatable(false);
    titleBar.setFloatable(false);
    this.add(jPanel1, BorderLayout.CENTER);
    editorToolBar.add(btn_New_Note, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(historyBackB, null);
    editorToolBar.add(historyForwardB, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(undoB, null);
    editorToolBar.add(redoB, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(cutB, null);
    editorToolBar.add(copyB, null);
    editorToolBar.add(pasteB, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(insDateB, null);
    editorToolBar.add(insTimeB, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(importB, null);
    editorToolBar.add(exportB, null);
    editorToolBar.addSeparator(new Dimension(8, 24));
    editorToolBar.add(previewB, null);
    // editorToolBar.add(printB, null);
    jPanel1.add(editorToolBar, BorderLayout.NORTH);
    jPanel1.add(editor, BorderLayout.CENTER);
    this.add(titleBar, BorderLayout.NORTH);
    titleBar.add(titleLabel, null);
    titleBar.add(titleField, null);
    initCSS();
    editor.editor.setAntiAlias(
        Configuration.get("ANTIALIAS_TEXT").toString().equalsIgnoreCase("yes"));
    // editor.editor.enableInputMethods(false);
    // editor.editor.getInputContext().selectInputMethod(Locale.getDefault());
    titleField.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent ke) {
            if (ke.getKeyCode() == KeyEvent.VK_ENTER) editor.editor.requestFocus();
          }

          public void keyReleased(KeyEvent arg0) {}

          public void keyTyped(KeyEvent arg0) {}
        });
  }
  void jbInit() throws Exception {
    toolBar.setFloatable(false);
    this.setLayout(borderLayout1);
    newResB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/addresource.png")));
    newResB.setEnabled(true);
    newResB.setMaximumSize(new Dimension(24, 24));
    newResB.setMinimumSize(new Dimension(24, 24));
    newResB.setToolTipText(Local.getString("New resource"));
    newResB.setRequestFocusEnabled(false);
    newResB.setPreferredSize(new Dimension(24, 24));
    newResB.setFocusable(false);
    newResB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newResB_actionPerformed(e);
          }
        });
    newResB.setBorderPainted(false);
    resourcesTable.setMaximumSize(new Dimension(32767, 32767));
    resourcesTable.setRowHeight(24);
    removeResB.setBorderPainted(false);
    removeResB.setFocusable(false);
    removeResB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            removeResB_actionPerformed(e);
          }
        });
    removeResB.setPreferredSize(new Dimension(24, 24));
    removeResB.setRequestFocusEnabled(false);
    removeResB.setToolTipText(Local.getString("Remove resource"));
    removeResB.setMinimumSize(new Dimension(24, 24));
    removeResB.setMaximumSize(new Dimension(24, 24));
    removeResB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/removeresource.png")));
    removeResB.setEnabled(false);
    scrollPane.getViewport().setBackground(Color.white);
    toolBar.addSeparator(new Dimension(8, 24));
    toolBar.addSeparator(new Dimension(8, 24));

    PopupListener ppListener = new PopupListener();
    scrollPane.addMouseListener(ppListener);
    resourcesTable.addMouseListener(ppListener);

    resourcesTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                boolean enbl =
                    (resourcesTable.getRowCount() > 0) && (resourcesTable.getSelectedRow() > -1);

                removeResB.setEnabled(enbl);
                ppRemoveRes.setEnabled(enbl);
                ppRun.setEnabled(enbl);
              }
            });
    refreshB.setBorderPainted(false);
    refreshB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refreshB_actionPerformed(e);
          }
        });
    refreshB.setFocusable(false);
    refreshB.setPreferredSize(new Dimension(24, 24));
    refreshB.setRequestFocusEnabled(false);
    refreshB.setToolTipText(Local.getString("Refresh"));
    refreshB.setMinimumSize(new Dimension(24, 24));
    refreshB.setMaximumSize(new Dimension(24, 24));
    refreshB.setEnabled(true);
    refreshB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/refreshres.png")));
    resPPMenu.setFont(new java.awt.Font("Dialog", 1, 10));
    ppRun.setFont(new java.awt.Font("Dialog", 1, 11));
    ppRun.setText(Local.getString("Open resource") + "...");
    ppRun.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ppRun_actionPerformed(e);
          }
        });
    ppRun.setEnabled(false);

    ppRemoveRes.setFont(new java.awt.Font("Dialog", 1, 11));
    ppRemoveRes.setText(Local.getString("Remove resource"));
    ppRemoveRes.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ppRemoveRes_actionPerformed(e);
          }
        });
    ppRemoveRes.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/removeresource.png")));
    ppRemoveRes.setEnabled(false);
    ppNewRes.setFont(new java.awt.Font("Dialog", 1, 11));
    ppNewRes.setText(Local.getString("New resource") + "...");
    ppNewRes.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ppNewRes_actionPerformed(e);
          }
        });
    ppNewRes.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/addresource.png")));

    ppRefresh.setFont(new java.awt.Font("Dialog", 1, 11));
    ppRefresh.setText(Local.getString("Refresh"));
    ppRefresh.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ppRefresh_actionPerformed(e);
          }
        });
    ppRefresh.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/refreshres.png")));

    toolBar.add(newResB, null);
    toolBar.add(removeResB, null);
    toolBar.addSeparator();
    toolBar.add(refreshB, null);
    this.add(scrollPane, BorderLayout.CENTER);
    scrollPane.getViewport().add(resourcesTable, null);
    this.add(toolBar, BorderLayout.NORTH);
    resPPMenu.add(ppRun);
    resPPMenu.addSeparator();
    resPPMenu.add(ppNewRes);
    resPPMenu.add(ppRemoveRes);
    resPPMenu.addSeparator();
    resPPMenu.add(ppRefresh);

    // remove resources using the DEL key
    resourcesTable.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent e) {
            if (resourcesTable.getSelectedRows().length > 0 && e.getKeyCode() == KeyEvent.VK_DELETE)
              ppRemoveRes_actionPerformed(null);
          }

          public void keyReleased(KeyEvent e) {}

          public void keyTyped(KeyEvent e) {}
        });
  }
  private JToolBar makeToolBar() {
    JToolBar tool = new JToolBar();
    tool.setFloatable(false);

    // Setup the buttons
    save.setRequestFocusEnabled(false);
    tool.add(save);
    tool.addSeparator();

    JButton button;

    button = addToolButton("GameInformationFrame.CUT"); // $NON-NLS-1$
    tool.add(button);
    button = addToolButton("GameInformationFrame.COPY"); // $NON-NLS-1$
    tool.add(button);
    button = addToolButton("GameInformationFrame.PASTE"); // $NON-NLS-1$
    tool.add(button);

    tool.addSeparator();

    button = new JButton(undoManager.getUndoAction());
    button.setText("");
    button.setToolTipText(Messages.getString("GameInformationFrame.UNDO")); // $NON-NLS-1$
    tool.add(button);
    button = new JButton(undoManager.getRedoAction());
    button.setText("");
    button.setToolTipText(Messages.getString("GameInformationFrame.REDO")); // $NON-NLS-1$
    tool.add(button);

    tool.addSeparator();

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    cbFonts = new JComboBox<String>(fontNames);
    cbFonts.setRequestFocusEnabled(false);
    cbFonts.setMaximumSize(cbFonts.getPreferredSize());
    cbFonts.setEditable(true);
    ActionListener lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (fFamilyChange) {
              fFamilyChange = false;
              return;
            }
            editor.grabFocus();
            setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString());
          }
        };

    cbFonts.addActionListener(lst);
    tool.add(cbFonts);
    tool.addSeparator();
    sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1));
    sSizes.setRequestFocusEnabled(false);
    sSizes.setMaximumSize(sSizes.getPreferredSize());
    sSizes.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            if (fSizeChange) {
              fSizeChange = false;
              return;
            }
            setSelectionAttribute(StyleConstants.Size, sSizes.getValue());
            editor.grabFocus();
          }
        });
    tool.add(sSizes);
    tool.addSeparator();

    tbBold = addToggleButton("GameInformationFrame.BOLD"); // $NON-NLS-1$
    tbBold.setRequestFocusEnabled(false);
    tool.add(tbBold);
    tbItalic = addToggleButton("GameInformationFrame.ITALIC"); // $NON-NLS-1$
    tbItalic.setRequestFocusEnabled(false);
    tool.add(tbItalic);
    tbUnderline = addToggleButton("GameInformationFrame.UNDERLINE"); // $NON-NLS-1$
    tbUnderline.setRequestFocusEnabled(false);
    tool.add(tbUnderline);

    tool.addSeparator();

    tbLeft = addToggleButton("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    tbLeft.setRequestFocusEnabled(false);
    tbLeft.setSelected(true);
    tool.add(tbLeft);
    tbCenter = addToggleButton("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    tbCenter.setRequestFocusEnabled(false);
    tool.add(tbCenter);
    tbRight = addToggleButton("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    tbRight.setRequestFocusEnabled(false);
    tool.add(tbRight);

    tool.addSeparator();

    JButton butFontColor =
        new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    butFontColor.setRequestFocusEnabled(false);
    butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    butFontColor.addActionListener(this);
    butFontColor.setToolTipText(
        Messages.getString("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    tool.add(butFontColor);
    JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$
    but.setRequestFocusEnabled(false);
    but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$
    but.addActionListener(this);
    but.setToolTipText(Messages.getString("GameInformationFrame.COLOR")); // $NON-NLS-1$
    tool.add(but);

    return tool;
  }
  public EmbeditorCompletionLookup(Project project, final JBTerminal terminal) {
    super(new JPanel(new BorderLayout()));

    CollectionListModel<LookupElement> model = new CollectionListModel<LookupElement>();

    myList =
        new JBList(model) {
          @Override
          protected void processKeyEvent(final KeyEvent e) {
            final char keyChar = e.getKeyChar();

            if ((keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_TAB)) {
              LookupElement lookupElement = (LookupElement) myList.getSelectedValue();
              try {
                terminal
                    .getEmulator()
                    .sendString(lookupElement.getLookupString().substring(myPrefixLength));
              } catch (RuntimeException e1) {
                e1.printStackTrace(); // TODO
              }
              doHide();
            }

            if (keyChar == KeyEvent.VK_ESCAPE) {
              doHide();
            }

            super.processKeyEvent(e);
          }

          ExpandableItemsHandler<Integer> myExtender = new CompletionExtender(this);

          @NotNull
          @Override
          public ExpandableItemsHandler<Integer> getExpandableItemsHandler() {
            return myExtender;
          }
        };

    myScrollBarIncreaseButton = new JButton();
    myScrollBarIncreaseButton.setFocusable(false);
    myScrollBarIncreaseButton.setRequestFocusEnabled(false);

    myScrollPane = new JBScrollPane(myList);
    myScrollPane.setViewportBorder(new EmptyBorder(0, 0, 0, 0));
    myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    myScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(13, -1));
    myScrollPane
        .getVerticalScrollBar()
        .setUI(
            new ButtonlessScrollBarUI() {
              @Override
              protected JButton createIncreaseButton(int orientation) {
                return myScrollBarIncreaseButton;
              }
            });
    getComponent().add(myLayeredPane, BorderLayout.CENTER);

    myLayeredPane.mainPanel.add(myScrollPane, BorderLayout.CENTER);
    myScrollPane.setBorder(null);

    myCellRenderer = new EmbeditorLookupCellRenderer(this, terminal.getColorScheme());
    myList.setCellRenderer(myCellRenderer);
  }