private JPanel createPanel2() {
    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            new JideTitledBorder(
                new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
                "AutoCompletion with list and tree",
                JideTitledBorder.LEADING,
                JideTitledBorder.ABOVE_TOP),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    // create tree combobox
    final JTextField treeTextField = new JTextField();
    treeTextField.setName("AutoCompletion JTextField with JTree");
    SelectAllUtils.install(treeTextField);
    final JTree tree = new JTree();
    tree.setVisibleRowCount(10);
    final TreeSearchable searchable = new TreeSearchable(tree);
    searchable.setRecursive(true);
    new AutoCompletion(treeTextField, searchable);
    panel.add(new JLabel("AutoCompletion JTextField with JTree"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(treeTextField);
    panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX);
    panel.add(new JScrollPane(tree));
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    // create font name combobox
    final JTextField fontNameTextField = new JTextField();
    fontNameTextField.setName("AutoCompletion JTextField with JList");
    SelectAllUtils.install(fontNameTextField);
    final JList fontNameList = new JList(_fontNames);
    fontNameList.setVisibleRowCount(10);
    new AutoCompletion(fontNameTextField, new ListSearchable(fontNameList));
    panel.add(new JLabel("AutoCompletion JTextField with JList"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(fontNameTextField);
    panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX);
    panel.add(new JScrollPane(fontNameList));
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    return panel;
  }
  private JPanel createPanel1() {
    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            new JideTitledBorder(
                new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
                "AutoCompletion combo box and text field",
                JideTitledBorder.LEADING,
                JideTitledBorder.ABOVE_TOP),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    JComboBox autoCompletionComboBox = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBox.setName("AutoCompletion JComboBox (Strict)");
    autoCompletionComboBox.setToolTipText("AutoCompletion JComboBox (Strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBox);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    AutoCompletionComboBox autoCompletionComboBoxNotStrict = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBoxNotStrict.setStrict(false);
    autoCompletionComboBoxNotStrict.setName("AutoCompletion JComboBox (Not strict)");
    autoCompletionComboBoxNotStrict.setToolTipText("AutoCompletion JComboBox (Not strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Not strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBoxNotStrict);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    // create tree combobox
    final JTextField textField = new JTextField();
    textField.setName("AutoCompletion JTextField with a hidden data");
    SelectAllUtils.install(textField);
    new AutoCompletion(textField, _fontList);
    panel.add(new JLabel("AutoCompletion JTextField with a hidden data"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(textField);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    //        panel.add(Box.createVerticalStrut(24), JideBoxLayout.FIX);
    //        panel.add(new JLabel("As comparisons:"));
    //        panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);
    //
    //        JComboBox searchableComboBox = new JComboBox(_fontNames);
    //        searchableComboBox.setEditable(false);
    //        SearchableUtils.installSearchable(searchableComboBox);
    //        searchableComboBox.setToolTipText("Searchable JComboBox");
    //        panel.add(new JLabel("Searchable JComboBox"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(searchableComboBox);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);
    //
    //        JTextField completionTextField = new JTextField();
    //        new ListCompletion(completionTextField, _fontNames);
    //        completionTextField.setToolTipText("Completion JTextField (not auto-complete)");
    //        panel.add(new JLabel("Completion JTextField (not auto-complete)"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(completionTextField);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    return panel;
  }
  private void initPanel() {

    mapButtons = new HashMap<>();

    for (Commontags commontags : CommontagsTools.getAll()) {
      mapAllTags.put(commontags.getText(), commontags);
    }

    int tagnum = 1;
    for (Commontags selectedTags : listSelectedTags) {
      if (tagnum % MAXLINE == 0) {
        add(createButton(selectedTags), RiverLayout.LINE_BREAK);
      } else {
        add(createButton(selectedTags), RiverLayout.LEFT);
      }
      tagnum++;
    }

    if (editmode) {
      txtTags = new JTextField(10);

      SelectAllUtils.install(txtTags);
      ac = new AutoCompletion(txtTags, mapAllTags.keySet().toArray(new String[] {}));

      ac.setStrict(false);
      ac.setStrictCompletion(false);
      txtTags.addActionListener(e -> cmbTagsActionPerformed(e));

      txtTags.addFocusListener(
          new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
              cmbTagsActionPerformed(null);
            }
          });

      txtTags.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
              char c = e.getKeyChar();
              if (Character.isAlphabetic(c) || Character.isDigit(c)) {
                super.keyTyped(e);
              } else {
                e.consume();
              }
            }
          });

      add(txtTags);

      btnPickTags =
          GUITools.getTinyButton("opde.tags.pnlcommontags.allTags", SYSConst.icon22checkbox);
      btnPickTags.setPressedIcon(SYSConst.icon22Pressed);
      btnPickTags.addActionListener(
          e -> {
            final JidePopup popup = new JidePopup();
            JPanel pnl = new JPanel(new BorderLayout());
            pnl.add(new JScrollPane(getClickableTagsPanel()), BorderLayout.CENTER);
            //                        JButton btnApply = new JButton(SYSConst.icon22apply);
            //                        pnl.add(btnApply, BorderLayout.SOUTH);
            //
            //                        btnApply.addActionListener(new ActionListener() {
            //                            @Override
            //                            public void actionPerformed(ActionEvent ae) {
            //                                popup.hidePopup();
            //                            }
            //                        });

            popup.setMovable(false);
            popup
                .getContentPane()
                .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.setOwner(btnPickTags);
            popup.removeExcludedComponent(btnPickTags);
            pnl.setPreferredSize(new Dimension(400, 200));
            popup.getContentPane().add(pnl);
            popup.setDefaultFocusComponent(pnl);

            popup.addPopupMenuListener(
                new PopupMenuListener() {
                  @Override
                  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    OPDE.debug("popupMenuWillBecomeVisible");
                  }

                  @Override
                  public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                    SwingUtilities.invokeLater(
                        () -> {
                          removeAll();

                          add(txtTags);
                          if (btnPickTags != null) {
                            add(btnPickTags);
                          }
                          int tagnum1 = 1;

                          for (JButton btn : mapButtons.values()) {
                            if (tagnum1 % MAXLINE == 0) {
                              add(btn, RiverLayout.LINE_BREAK);
                            } else {
                              add(btn, RiverLayout.LEFT);
                            }
                            tagnum1++;
                          }

                          revalidate();
                          repaint();
                        });
                  }

                  @Override
                  public void popupMenuCanceled(PopupMenuEvent e) {
                    OPDE.debug("popupMenuCanceled");
                  }
                });

            GUITools.showPopup(popup, SwingConstants.WEST);
          });

      add(btnPickTags);
    }
  }
  public Component getDemoPanel() {
    final String[] fontNames = DemoData.getFontNames();
    // create file text field
    List<String> urls = null;
    try {
      urls = readUrls();
    } catch (IOException e) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }

    JTextField urlTextField = new JTextField("http://");
    urlTextField.setName("URL IntelliHint");
    SelectAllUtils.install(urlTextField);
    ListDataIntelliHints intelliHints = new ListDataIntelliHints<String>(urlTextField, urls);
    intelliHints.setCaseSensitive(false);

    JTextField pathTextField = new JTextField();
    SelectAllUtils.install(pathTextField);
    FileIntelliHints fileIntelliHints = new FileIntelliHints(pathTextField);
    fileIntelliHints.setFilter(
        new FilenameFilter() {
          public boolean accept(File dir, String name) {
            return !_applyFileFilter
                || dir.getAbsolutePath().contains("Program")
                || name.contains("Program");
          }
        });
    fileIntelliHints.setFolderOnly(false);
    fileIntelliHints.setFollowCaret(true);
    fileIntelliHints.setShowFullPath(false);

    // create file text field
    JTextField fileTextField = new JTextField();
    fileTextField.setName("File IntelliHint");
    SelectAllUtils.install(fileTextField);
    new FileIntelliHints(fileTextField);

    // create file text field
    JTextArea fileTextArea = new JTextArea();
    new FileIntelliHints(fileTextArea);
    fileTextArea.setRows(4);

    // create file text field
    JTextField fontTextField = new JTextField();
    fontTextField.setName("Font IntelliHint");
    SelectAllUtils.install(fontTextField);
    ListDataIntelliHints fontIntelliHints =
        new ListDataIntelliHints<String>(fontTextField, fontNames);
    fontIntelliHints.setCaseSensitive(false);

    JTextField textField = new JTextField();
    SelectAllUtils.install(textField);
    //noinspection UnusedDeclaration
    new AbstractListIntelliHints(textField) {
      protected JLabel _messageLabel;

      @Override
      public JComponent createHintsComponent() {
        JPanel panel = (JPanel) super.createHintsComponent();
        _messageLabel = new JLabel();
        panel.add(_messageLabel, BorderLayout.BEFORE_FIRST_LINE);
        return panel;
      }

      // update list model depending on the data in textfield
      public boolean updateHints(Object value) {
        if (value == null) {
          return false;
        }
        String s = value.toString();
        s = s.trim();
        if (s.length() == 0) {
          return false;
        }
        try {
          long l = Long.parseLong(s);
          boolean prime = isProbablePrime(l);
          _messageLabel.setText("");
          if (prime) {
            return false;
          } else {
            Vector<Long> list = new Vector<Long>();
            long nextPrime = l;
            for (int i = 0; i < 10; i++) {
              nextPrime = nextPrime(nextPrime);
              list.add(nextPrime);
            }
            setListData(list);
            _messageLabel.setText("Next 10 prime numbers:");
            _messageLabel.setForeground(Color.DARK_GRAY);
            return true;
          }
        } catch (NumberFormatException e) {
          setListData(new Object[0]);
          _messageLabel.setText("Invalid long number");
          setListData(new Object[0]);
          _messageLabel.setForeground(Color.RED);
          return true;
        }
      }
    };

    DefaultTableModel model =
        new DefaultTableModel(0, 1) {
          private static final long serialVersionUID = -2794741068912785630L;

          @Override
          public Class<?> getColumnClass(int columnIndex) {
            return String.class;
          }

          @Override
          public String getColumnName(int column) {
            return "Font";
          }
        };
    model.addRow(new Object[] {"Arial"});
    model.addRow(new Object[] {"Tahoma"});
    SortableTable table = new SortableTable(model);
    table
        .getColumnModel()
        .getColumn(0)
        .setCellEditor(
            new TextFieldCellEditor(String.class) {
              private static final long serialVersionUID = 2023654568542192380L;

              @Override
              protected JTextField createTextField() {
                JTextField cellEditorTextField = new JTextField();
                ListDataIntelliHints fontIntellihints =
                    new ListDataIntelliHints<String>(cellEditorTextField, fontNames);
                fontIntellihints.setCaseSensitive(false);
                return cellEditorTextField;
              }
            });
    table.setPreferredScrollableViewportSize(new Dimension(100, 100));

    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 3));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    panel.add(new JLabel("ListDataIntelliHints TextField for URLs: "));
    panel.add(urlTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    // create path text field
    panel.add(
        new JLabel("FileIntelliHints TextField for paths (folders only, show partial path):"));
    panel.add(pathTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(
        new JLabel("FileIntelliHints TextField for files (files and folders, show full path):"));
    panel.add(fileTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("FileIntelliHints TextArea for files (each line is for a new file):"));
    panel.add(new JScrollPane(fileTextArea));
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("IntelliHints TextField to choose a font:"));
    panel.add(fontTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("A custom IntelliHints for prime numbers: "));
    panel.add(textField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("Using IntelliHint in JTable's cell editor"));
    panel.add(new JScrollPane(table), JideBoxLayout.FLEXIBLE);

    panel.add(Box.createGlue(), JideBoxLayout.VARY);

    return panel;
  }