Exemplo n.º 1
0
  /** Populate searchers. */
  private void populateSearchers() {
    JMenu searchersMenu = this.searchersMenu;
    searchersMenu.removeAll();
    final ToolsSettings settings = ToolsSettings.getInstance();
    Collection<SearchEngine> searchEngines = settings.getSearchEngines();
    SearchEngine selectedEngine = settings.getSelectedSearchEngine();
    if (searchEngines != null) {
      for (SearchEngine se : searchEngines) {
        final SearchEngine finalSe = se;
        JRadioButtonMenuItem item = new JRadioButtonMenuItem();
        item.setAction(
            new AbstractAction() {

              private static final long serialVersionUID = 1L;

              @Override
              public void actionPerformed(ActionEvent e) {
                settings.setSelectedSearchEngine(finalSe);
                settings.save();
                ComponentSource.this.updateSearchButtonTooltip();
              }
            });
        item.setSelected(se == selectedEngine);
        item.setText(se.getName());
        item.setToolTipText(se.getDescription());
        searchersMenu.add(item);
      }
    }
  }
Exemplo n.º 2
0
 private static JRadioButtonMenuItem createLookAndFeelItem(
     String lafName, String lafClassName, final ButtonGroup lookAndFeelRadioGroup) {
   JRadioButtonMenuItem lafItem = new JRadioButtonMenuItem();
   lafItem.setSelected(lafClassName.equals(lookAndFeel));
   lafItem.setHideActionText(true);
   lafItem.setAction(
       new AbstractAction() {
         @Override
         public void actionPerformed(ActionEvent e) {
           ButtonModel m = lookAndFeelRadioGroup.getSelection();
           try {
             setLookAndFeel(m.getActionCommand());
           } catch (ClassNotFoundException
               | InstantiationException
               | IllegalAccessException
               | UnsupportedLookAndFeelException ex) {
             ex.printStackTrace();
           }
         }
       });
   lafItem.setText(lafName);
   lafItem.setActionCommand(lafClassName);
   lookAndFeelRadioGroup.add(lafItem);
   return lafItem;
 }