/*-------------------------------------------------------------------------*/
  protected PlayerBodyPartTablePanel(String title, int dirtyFlag) {
    this.dirtyFlag = dirtyFlag;

    this.setLayout(new GridLayout(5, 2));

    head = new JComboBox();
    head.addActionListener(this);
    torso = new JComboBox();
    torso.addActionListener(this);
    leg = new JComboBox();
    leg.addActionListener(this);
    hand = new JComboBox();
    hand.addActionListener(this);
    foot = new JComboBox();
    foot.addActionListener(this);

    this.add(new JLabel("Head:"));
    this.add(head);
    this.add(new JLabel("Torso:"));
    this.add(torso);
    this.add(new JLabel("Leg:"));
    this.add(leg);
    this.add(new JLabel("Hand:"));
    this.add(hand);
    this.add(new JLabel("Foot:"));
    this.add(foot);

    this.setBorder(BorderFactory.createTitledBorder(title));
  }
Esempio n. 2
0
  private void init() {
    agents = new JComboBox(model);
    agents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            stateChanged(event);
          }
        });
    agents.addActionListener(TextChangesListener.getInstance());
    ctm = new CreationTableModel();
    datatable = new JTable(ctm);
    datatable.setShowGrid(false);
    datatable.setEnabled(false);
    datatable.setTableHeader(null);
    datatable.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
    JPanel apanel = new JPanel(new BorderLayout());
    apanel.add(new JLabel("Who took the photo: "), BorderLayout.WEST);
    apanel.add(agents, BorderLayout.CENTER);
    JPanel tablePanel = new JPanel(new BorderLayout());
    tablePanel.add(new JScrollPane(datatable), BorderLayout.CENTER);

    datatable.getColumnModel().getColumn(0).setMaxWidth(120);
    datatable.getColumnModel().getColumn(0).setMinWidth(80);

    datatable.addKeyListener(TextChangesListener.getInstance());

    this.add(
        ComponentFactory.createTitledPanel("Creator of the image:", apanel), BorderLayout.NORTH);
    this.add(
        ComponentFactory.createTitledPanel("Creation, EXIF & technical information:", tablePanel),
        BorderLayout.CENTER);
    this.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.WEST);
  }
Esempio n. 3
0
  private void createUI() {
    ShowMaxAction showMaxAction = new ShowMaxAction();
    showMaxCheckBox = new JCheckBox(showMaxAction);
    showMaxCheckBox.setOpaque(false);
    showMaxCheckBox.setSelected(true);
    saveFileChooser = new JFileChooser();
    saveFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileFilter pngFileFilter = new PngFileFilter();
    saveFileChooser.setFileFilter(pngFileFilter);
    graphImageFactories =
        new GraphImageProducer[] {
          new TwentyMinutesProducer(mainFrame),
          new TwoHoursProducer(mainFrame),
          new TenHoursProducer(mainFrame),
          new OneDayProducer(mainFrame),
          new SevenDaysProducer(mainFrame),
          new ThirtyDaysProducer(mainFrame),
          new NinetyDaysProducer(mainFrame),
          new OneYearProducer(mainFrame),
        };

    JPanel graphPanel = new JPanel(new GridLayout(1, 1));
    graphLabel = new JLabel();
    graphPanel.add(graphLabel);

    setLayout(new BorderLayout());
    add(graphPanel, BorderLayout.CENTER);
    timerangeComboBox =
        new JComboBox(
            new Object[] {
              "20 minutes",
              "2 hours",
              "10 hours",
              "1 day",
              "7 days",
              "30 days",
              "90 days",
              "1 year",
            });
    timerangeComboBox.addActionListener(new TimerangeActionListener());

    sourcesComboBox = new JComboBox();
    sourcesComboBox.addActionListener(new SourcesActionListener());

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(new JLabel("Source: "));
    toolbar.add(sourcesComboBox);
    toolbar.addSeparator();
    toolbar.add(new JLabel("Timerange: "));
    toolbar.add(timerangeComboBox);
    toolbar.add(showMaxCheckBox);
    toolbar.addSeparator();
    toolbar.add(new JButton(new SaveAction()));
    add(toolbar, BorderLayout.NORTH);
    setSelectedGraph(0);
  }
    public GlobalAttributes() {
      setLayout(new BorderLayout());
      LabelledList list =
          new LabelledList(includeAggregationMethodAttributes() ? "Add Data..." : "Redraw");
      add(list, BorderLayout.CENTER);

      if (includeAggregationMethodAttributes()) {
        NumberTextField stepsField =
            new NumberTextField(1, true) {
              public double newValue(double value) {
                value = (long) value;
                if (value <= 0) return currentValue;
                else {
                  interval = (long) value;
                  return value;
                }
              }
            };

        list.addLabelled("Every", stepsField);
        list.addLabelled("", new JLabel("...Timesteps"));

        String[] optionsLabel = {"Current", "Maximum", "Minimum", "Mean"};
        final JComboBox optionsBox = new JComboBox(optionsLabel);
        optionsBox.setSelectedIndex(aggregationMethod);
        optionsBox.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                aggregationMethod = optionsBox.getSelectedIndex();
              }
            });
        list.addLabelled("Using", optionsBox);
      }

      String[] optionsLabel2 =
          new String[] {
            "When Adding Data",
            "Every 0.1 Seconds",
            "Every 0.5 Seconds",
            "Every Second",
            "Every 2 Seconds",
            "Every 5 Seconds",
            "Every 10 Seconds",
            "Never"
          };
      final JComboBox optionsBox2 = new JComboBox(optionsLabel2);
      optionsBox2.setSelectedIndex(redraw);
      optionsBox2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              redraw = optionsBox2.getSelectedIndex();
              generator.update(); // keep up-to-date
            }
          });
      if (includeAggregationMethodAttributes()) list.addLabelled("Redraw", optionsBox2);
      else list.add(optionsBox2);
    }
Esempio n. 5
0
  public void buildPopulationBox() {
    rebuilding = true;
    populationBox.removeAll();
    peopleList = new ArrayList<Object>();
    famList = new ArrayList<Family>();
    peopleList.addAll(ctxt.individualCensus);
    String plur = (peopleList.size() == 1 ? "" : "s");
    populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS));
    populationBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Current Population"));
    populationBox.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(8, 0)));
    indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur);
    indivLabel.setAlignmentX(0.5f);
    populationBox.add(indivLabel);
    if (peopleList.size() > 0) {
      JPanel indivBtnBox = new JPanel();
      indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] indMenu = genIndMenu(peopleList);
      indPick = new JComboBox(indMenu);
      indPick.addActionListener(listener);
      indPick.setActionCommand("view/edit person");
      indPick.setMinimumSize(sizer2);
      indPick.setMaximumSize(sizer2);
      indPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Person"));
      indivBtnBox.add(indPick);
      populationBox.add(indivBtnBox);
    } //  end of if-any-people-exist

    famList.addAll(ctxt.familyCensus); //  end of filtering deleted records
    plur = (famList.size() == 1 ? "y" : "ies");
    famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
    famLabel.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(0, 4)));
    populationBox.add(famLabel);
    if (famList.size() > 0) {
      JPanel famBtnBox = new JPanel();
      famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] famMenu = genFamMenu(famList);
      famPick = new JComboBox(famMenu);
      famPick.addActionListener(listener);
      famPick.setActionCommand("view/edit family");
      famPick.setMinimumSize(sizer2);
      famPick.setMaximumSize(sizer2);
      famPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Family"));
      famBtnBox.add(famPick);
      populationBox.add(famBtnBox);
    } //  end of if-any-families-exist
    rebuilding = false;
  } //  end of method buildPopulationBox
Esempio n. 6
0
  /*
  Post: sets up all the options visually
  */
  public Options() {

    valuesArray = new ArrayList<Integer>();
    populateRandomArray();

    // size of the array
    enterSize = new JLabel("Array size:");
    arraySizeEntry = new JTextField("", 3);
    arraySizeEntry.addActionListener(this);
    arraySizeEntry.getDocument().addDocumentListener(new DocListener());

    // algorithm on top
    topAlgo = new JLabel("Top:");
    String[] topAlgos = {"Selection Sort", "Insertion Sort", "Bubble Sort", "Merge Sort"};
    chooseTopAlgo = new JComboBox(topAlgos);
    chooseTopAlgo.addActionListener(this);

    // algorithm on bottom
    bottomAlgo = new JLabel("Bottom:");
    String[] bottomAlgos = {"Selection Sort", "Insertion Sort", "Bubble Sort", "Merge Sort"};
    chooseBottomAlgo = new JComboBox(bottomAlgos);
    chooseBottomAlgo.addActionListener(this);

    // average case or worst case
    caseLabel = new JLabel("Choose case:");
    String[] cases = {"Average Case", "Worst Case"};
    chooseCase = new JComboBox(cases);
    chooseCase.addActionListener(this);

    // delay of comparisons in the visualizer
    enterSpeed = new JLabel("Delay:");
    speedEntry = new JTextField("10", 2);
    speedEntry.addActionListener(this);
    speedEntry.getDocument().addDocumentListener(this);

    // run button (runs the visualizer)
    run = new JButton("Run");
    run.addActionListener(this);
    // adding everything to the panel
    add(enterSize);
    add(arraySizeEntry);
    add(topAlgo);
    add(chooseTopAlgo);
    add(bottomAlgo);
    add(chooseBottomAlgo);
    add(caseLabel);
    add(chooseCase);
    add(enterSpeed);
    add(speedEntry);
    add(run);
  }
  @Override
  protected JComponent createNorthPanel() {
    JBLabel descriptionLabel = new JBLabel("<html>" + makeDescription() + "</html>");

    final JComboBox repositorySelector =
        new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class));
    repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector));
    repositorySelector.setSelectedItem(myInitialRepository);
    repositorySelector.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            List<GitCommit> commits =
                myCommits.get((GitRepository) repositorySelector.getSelectedItem());
            myCommitListWithDiffPanel.setCommits(new ArrayList<GitCommit>(commits));
          }
        });

    JPanel repoSelectorPanel = new JPanel(new BorderLayout());
    JBLabel label = new JBLabel("Repository: ");
    label.setLabelFor(repoSelectorPanel);
    repoSelectorPanel.add(label, BorderLayout.WEST);
    repoSelectorPanel.add(repositorySelector);

    if (myRepositories.size() < 2) {
      repoSelectorPanel.setVisible(false);
    }

    JPanel northPanel = new JPanel(new BorderLayout());
    northPanel.add(descriptionLabel);
    northPanel.add(repoSelectorPanel, BorderLayout.SOUTH);
    return northPanel;
  }
  private void createComponents(JPanel p) {
    String tt = "Any of these:  45.5 -120.2   or   45 30 0 n 120 12 0 w   or   Seattle";

    JComboBox field = new JComboBox();
    field.setOpaque(false);
    field.setEditable(true);
    field.setLightWeightPopupEnabled(false);
    field.setPreferredSize(new Dimension(200, field.getPreferredSize().height));
    field.setToolTipText(tt);

    JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png"));
    //            new
    // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png")));
    label.setOpaque(false);
    label.setToolTipText(tt);

    p.add(label, BorderLayout.WEST);
    p.add(field, BorderLayout.CENTER);

    field.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            performGazeteerAction(actionEvent);
          }
        });
  }
Esempio n. 9
0
 protected JComboBox getFileFileterComboBox(final FileTree ftree) {
   String[] filters = {
     "Artemis Files", "Sequence Files",
     "Feature Files", "All Files"
   };
   final JComboBox comboFilter = new JComboBox(filters);
   comboFilter.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           String select = (String) comboFilter.getSelectedItem();
           if (select.equals("Artemis Files")) ftree.setFilter(getArtemisFilter());
           else if (select.equals("Sequence Files")) ftree.setFilter(getSequenceFilter());
           else if (select.equals("Feature Files")) ftree.setFilter(getFeatureFilter());
           else if (select.equals("All Files")) {
             ftree.setFilter(
                 new FileFilter() {
                   public boolean accept(File pathname) {
                     if (pathname.getName().startsWith(".")) return false;
                     return true;
                   }
                 });
           }
         }
       });
   return comboFilter;
 }
 private JComboBox getOptionsRenderingMethodComboBox() {
   if (optionsRenderingMethodComboBox == null) {
     optionsRenderingMethodComboBox = new JComboBox(new String[] {"Default", "Quality", "Speed"});
     optionsRenderingMethodComboBox.addActionListener(eventHandler);
   }
   return optionsRenderingMethodComboBox;
 }
 private JComboBox getOptionsRenderingAntialiasingComboBox() {
   if (optionsRenderingAntialiasingComboBox == null) {
     optionsRenderingAntialiasingComboBox = new JComboBox(new String[] {"Default", "On", "Off"});
     optionsRenderingAntialiasingComboBox.addActionListener(eventHandler);
   }
   return optionsRenderingAntialiasingComboBox;
 }
Esempio n. 12
0
  /** Method that creates the JComponents. */
  public void makeJComponents() {

    // button.
    choiceBox = new JComboBox(choiceArray);
    choiceBox.setEditable(false);
    choiceBox.addActionListener(this);
  }
Esempio n. 13
0
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
  @Override
  public JComponent createForm() {

    JComponent component = super.createForm();

    annotationComboBox.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
              Annotation annotation = (Annotation) value;
              this.setText(annotation.getBrief());
            } else {
              this.setText("-- select annotation --");
            }
            return this;
          }
        });

    component.setLayout(new FormLayout("right:p, 4dlu, left:p", "p, 4dlu, p, 4dlu, p, 4dlu, p"));

    CellConstraints cc = new CellConstraints();

    component.add(getLabel("annotationLabel"), cc.xy(1, 1));
    component.add(annotationComboBox, cc.xy(3, 1));
    component.add(getLabel("patternLabel"), cc.xy(1, 3));
    component.add(patternField, cc.xy(3, 3));
    component.add(getLabel("ciLabel"), cc.xy(1, 5));
    component.add(caseInsensitive, cc.xy(3, 5));
    component.add(getLabel("remove"), cc.xy(1, 7));
    component.add(removeMatched, cc.xy(3, 7));

    patternField.setEnabled(false);
    caseInsensitive.setSelected(true);
    caseInsensitive.setEnabled(false);

    // action listener will fill out a suggested pattern for selected annotation types
    annotationComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object obj = annotationComboBox.getSelectedItem();
            if (obj == null) {
              patternField.setEnabled(false);
              caseInsensitive.setEnabled(false);
              setEnabled(false);
            } else {
              patternField.setEnabled(true);
              caseInsensitive.setEnabled(true);
              patternField.setText(getDefault(obj.getClass()));
              patternField.setCaretPosition(0);
              setEnabled(true);
            }
          }
        });

    return component;
  }
  HeatMapControls(ControlBar creator) {
    super();
    parent = creator;

    setLayout(new BorderLayout());
    super.setPreferredSize(new Dimension(255, 170));

    String[] organisms = SpeciesTable.getOrganisms();
    String[] options = new String[organisms.length + 1];

    options[0] = "None";
    for (int i = 0; i < organisms.length; i++) {
      options[i + 1] = organisms[i];
    }

    species = new JComboBox(options);
    species.addActionListener(this);
    for (String str : SpeciesTable.getOrganisms()) {}

    super.add(species, BorderLayout.SOUTH);
    super.add(new Gradient(), BorderLayout.CENTER);
    super.add(new JLabel("Least"), BorderLayout.WEST);
    super.add(new JLabel("Most"), BorderLayout.EAST);
    super.add(new JLabel("Heat Map Controls"), BorderLayout.NORTH);
    super.setVisible(true);
  }
Esempio n. 16
0
  void populateStartDate() throws SQLException, Exception {
    startDateS.removeActionListener(this);
    startDateS.removeAllItems();
    dateRange.clear();
    if (sourceTable.sourceListModel.isSelectionEmpty() == false
        && sourceTable.getValueAt(sourceTable.getSelectedRow(), 0).toString() != null) {
      Statement MySQL_Statement = dbConn.createStatement();
      String getMinMaxSQL =
          "SELECT UNIX_TIMESTAMP(DATE_ADD(DATE(MIN(date_time)),INTERVAL 1 DAY)) AS min_date,UNIX_TIMESTAMP(DATE(MAX(date_time))) AS max_date FROM data_sa WHERE site_id = "
              + siteTable.getValueAt(siteTable.getSelectedRow(), 0)
              + " AND source_id = "
              + sourceTable.getValueAt(sourceTable.getSelectedRow(), 0);
      ResultSet minMaxResults = MySQL_Statement.executeQuery(getMinMaxSQL);
      if (minMaxResults.next()) {
        Calendar minCal = Calendar.getInstance();
        minCal.setTimeZone(TimeZone.getTimeZone("GMT+10"));
        minCal.setTimeInMillis(minMaxResults.getLong("min_date") * 1000);
        long maxCal = minMaxResults.getLong("max_date") * 1000;

        while (minCal.getTimeInMillis() <= maxCal) {
          dateRange.add(minCal.getTimeInMillis());
          startDateS.addItem(dateFormatter.format(minCal.getTimeInMillis()));
          minCal.add(Calendar.DATE, 1);
        }
        startDateS.setEnabled(true);
        populateEndDate();
      } else {
        throw new Exception("ERR:NoData");
      }
    } else { // This should never be able to happen
      throw new Exception("NoSource");
    }
    startDateS.addActionListener(this);
  }
 /**
  * Setup root chooser with specified elements and link selection to the current branch label.
  *
  * @param project a context project
  * @param roots git roots for the project
  * @param defaultRoot a default root
  * @param gitRootChooser git root selector
  * @param currentBranchLabel current branch label (might be null)
  */
 public static void setupRootChooser(
     @NotNull final Project project,
     @NotNull final List<VirtualFile> roots,
     @Nullable final VirtualFile defaultRoot,
     @NotNull final JComboBox gitRootChooser,
     @Nullable final JLabel currentBranchLabel) {
   for (VirtualFile root : roots) {
     gitRootChooser.addItem(root);
   }
   gitRootChooser.setRenderer(getVirtualFileListCellRenderer(gitRootChooser.getRenderer()));
   gitRootChooser.setSelectedItem(defaultRoot != null ? defaultRoot : roots.get(0));
   if (currentBranchLabel != null) {
     final ActionListener listener =
         new ActionListener() {
           public void actionPerformed(final ActionEvent e) {
             VirtualFile root = (VirtualFile) gitRootChooser.getSelectedItem();
             assert root != null : "The root must not be null";
             GitRepository repo =
                 GitRepositoryManager.getInstance(project).getRepositoryForRoot(root);
             assert repo != null : "The repository must not be null";
             GitBranch current = repo.getCurrentBranch();
             if (current == null) {
               currentBranchLabel.setText(NO_CURRENT_BRANCH);
             } else {
               currentBranchLabel.setText(current.getName());
             }
           }
         };
     listener.actionPerformed(null);
     gitRootChooser.addActionListener(listener);
   }
 }
  @Override
  public JComponent createOptionsPanel() {
    final JFormattedTextField valueField = prepareNumberEditor("m_limit");
    final JComboBox comboBox =
        new ComboBox(
            new Object[] {Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED});
    comboBox.setRenderer(
        new ListCellRendererWrapper() {
          @Override
          public void customize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof Scope) setText(((Scope) value).getText());
          }
        });
    comboBox.setSelectedItem(ignoreScope);
    comboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ignoreScope = (Scope) comboBox.getSelectedItem();
          }
        });
    comboBox.setPrototypeDisplayValue(Scope.PROTECTED);

    final FormBuilder formBuilder = FormBuilder.createFormBuilder();
    formBuilder.addLabeledComponent(getConfigurationLabel(), valueField);
    formBuilder.addLabeledComponent(
        InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(formBuilder.getPanel(), BorderLayout.NORTH);
    return panel;
  }
Esempio n. 19
0
  public ComboBoxDemo() {
    super(new BorderLayout());

    String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Pig"};

    // Create the combo box, select the item at index 4.
    // Indices start at 0, so 4 specifies the pig.
    JComboBox petList = new JComboBox(petStrings);
    petList.setSelectedIndex(4);
    petList.addActionListener(this);

    // Set up the picture.
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);
    updateLabel(petStrings[petList.getSelectedIndex()]);
    picture.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    // The preferred size is hard-coded to be the width of the
    // widest image and the height of the tallest image + the border.
    // A real program would compute this.
    picture.setPreferredSize(new Dimension(177, 122 + 10));

    // Lay out the demo.
    add(petList, BorderLayout.PAGE_START);
    add(picture, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  }
Esempio n. 20
0
  public Mapper() {
    super("Action/Input Mapper");
    setSize(500, 600);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel setupPane = new JPanel(new GridLayout(0, 1));
    JPanel classPane = new JPanel(new BorderLayout());
    classPane.add(new JLabel("Class: "), BorderLayout.WEST);
    classPane.add(nameF, BorderLayout.CENTER);
    classPane.add(stateC, BorderLayout.EAST);
    JPanel mapPane = new JPanel();
    mapPane.add(inputB);
    mapPane.add(actionB);
    mapPane.add(bindingB);

    setupPane.add(classPane);
    setupPane.add(mapPane);

    getContentPane().add(setupPane, BorderLayout.NORTH);
    getContentPane().add(new JScrollPane(results), BorderLayout.CENTER);

    nameF.addActionListener(this);
    stateC.addActionListener(this);
    stateC.setEditable(false);
    new Probe().loadAudioActions(); // !!!
    setVisible(true);
  }
Esempio n. 21
0
  public void setIndexer(LibrariesIndexer indexer) {
    this.indexer = indexer;

    DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
    DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem();

    categoryChooser.removeActionListener(categoryChooserActionListener);
    typeChooser.removeActionListener(typeChooserActionListener);

    // TODO: Remove setIndexer and make getContribModel 
    // return a FilteredAbstractTableModel
    getContribModel().setIndexer(indexer);

    categoryFilter = null;
    categoryChooser.removeAllItems();

    // Load categories
    categoryChooser.addItem(new DropdownAllItem());
    Collection<String> categories = indexer.getIndex().getCategories();
    for (String category : categories) {
      categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category));
    }

    categoryChooser.setEnabled(categoryChooser.getItemCount() > 1);

    categoryChooser.addActionListener(categoryChooserActionListener);
    if (previouslySelectedCategory != null) {
      categoryChooser.setSelectedItem(previouslySelectedCategory);
    } else {
      categoryChooser.setSelectedIndex(0);
    }

    typeFilter = null;
    typeChooser.removeAllItems();
    typeChooser.addItem(new DropdownAllItem());
    typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex()));
    java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes());
    Collections.sort(types, new LibraryTypeComparator());
    for (String type : types) {
      typeChooser.addItem(new DropdownLibraryOfTypeItem(type));
    }
    typeChooser.setEnabled(typeChooser.getItemCount() > 1);
    typeChooser.addActionListener(typeChooserActionListener);
    if (previouslySelectedType != null) {
      typeChooser.setSelectedItem(previouslySelectedType);
    } else {
      typeChooser.setSelectedIndex(0);
    }

    filterField.setEnabled(contribModel.getRowCount() > 0);

    // Create LibrariesInstaller tied with the provided index
    installer = new LibraryInstaller(indexer, platform) {
      @Override
      public void onProgress(Progress progress) {
        setProgress(progress);
      }
    };
  }
 private JComboBox getOptionsRenderingNoBuffersComboBox() {
   if (optionsRenderingNoBuffersComboBox == null) {
     optionsRenderingNoBuffersComboBox =
         new JComboBox(new String[] {"Single buffering", "Double buffering", "Triple buffering"});
     optionsRenderingNoBuffersComboBox.addActionListener(eventHandler);
   }
   return optionsRenderingNoBuffersComboBox;
 }
Esempio n. 23
0
 public DemoControls(ImageOps demo) {
   super(demo.name);
   this.demo = demo;
   setBackground(Color.gray);
   add(imgCombo = new JComboBox());
   imgCombo.setFont(font);
   for (int i = 0; i < ImageOps.imgName.length; i++) {
     imgCombo.addItem(ImageOps.imgName[i]);
   }
   imgCombo.addActionListener(this);
   add(opsCombo = new JComboBox());
   opsCombo.setFont(font);
   for (int i = 0; i < ImageOps.opsName.length; i++) {
     opsCombo.addItem(ImageOps.opsName[i]);
   }
   opsCombo.addActionListener(this);
 }
Esempio n. 24
0
  protected void attachTo(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
      extListener.startListeningTo(jc, extNotifier);
      listenedTo.add(jc);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
      return;
    }
    if (isProbablyAContainer(jc)) {
      attachToHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      listenedTo.add(jc);
      ((JList) jc).addListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).addActionListener(this);
    } else if (jc instanceof JTree) {
      listenedTo.add(jc);
      ((JTree) jc).getSelectionModel().addTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).addItemListener(this);
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.addPropertyChangeListener("value", this);
    } else if (jc instanceof JTextComponent) {
      listenedTo.add(jc);
      ((JTextComponent) jc).getDocument().addDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      listenedTo.add(jc);
      ((JColorChooser) jc).getSelectionModel().addChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).addChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).addChangeListener(this);
    } else if (jc instanceof JTable) {
      listenedTo.add(jc);
      ((JTable) jc).getSelectionModel().addListSelectionListener(this);
    } else {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "Don't know how to listen to a "
                + // NOI18N
                jc.getClass().getName());
      }
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.addPropertyChangeListener("name", this);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Begin listening to " + jc); // NOI18N
    }
  }
Esempio n. 25
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
Esempio n. 26
0
 @Override
 public void setSystemManager(SystemManager sm) {
   super.setSystemManager(sm);
   sm.getIoService().addIOServiceListener(this);
   filter.addCaretListener(lumberjack);
   filter.setAction(lumberjackAction);
   colors.addTreeSelectionListener(this);
   itemList.addActionListener(this);
   sceneElement = null;
 }
  public RendererOptions() {
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    renderers.addItem("Parallel");
    renderers.addItem("Serial");
    renderers.addActionListener(actionProvider.actionDelegate());
    renderers.setSelectedItem("Parallel");

    JPanel upper = new JPanel();
    upper.add(new LabeledItem("Render:", renderers));
    this.add(upper);
  }
Esempio n. 28
0
 // listeners
 public void ajouterActionListener() {
   for (int i = 0; i < mode.length; i++) {
     mode[i].addActionListener(this);
   }
   for (int j = 0; j < modeButton.length; j++) {
     modeButton[j].addActionListener(this);
   }
   optionCategories[0].addActionListener(this);
   optionCategories[1].addActionListener(this);
   comboCollection.addActionListener(this);
 }
  // WTF: this does not update packs!!
  // only updating info for selected pack. pulldown menus and info area!
  void updatePacks() {
    for (int i = 0; i < packPanels.size(); i++) {
      if (selectedPack == i && getIndex() >= 0) {
        ModPack pack = ModPack.getPackArray().get(getIndex());
        if (pack != null) {
          String mods = "";
          if (pack.getMods() != null) {
            mods += "<p>This pack contains the following mods by default:</p><ul>";
            for (String name : pack.getMods()) {
              mods += "<li>" + name + "</li>";
            }
            mods += "</ul>";
          }
          packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker());
          packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
          File tempDir =
              new File(
                  OSUtils.getCacheStorageLocation(), "ModPacks" + File.separator + pack.getDir());
          packInfo.setText(
              "<html><img src='file:///"
                  + tempDir.getPath()
                  + File.separator
                  + pack.getImageName()
                  + "' width=400 height=200></img> <br>"
                  + pack.getInfo()
                  + mods);
          packInfo.setCaretPosition(0);

          if (ModPack.getSelectedPack(isFTB()).getServerUrl().equals("")
              || ModPack.getSelectedPack(isFTB()).getServerUrl() == null) {
            server.setEnabled(false);
          } else {
            server.setEnabled(true);
          }
          String tempVer = Settings.getSettings().getPackVer(pack.getDir());
          version.removeActionListener(al);
          version.removeAllItems();
          version.addItem("Recommended");
          if (pack.getOldVersions() != null) {
            for (String s : pack.getOldVersions()) {
              version.addItem(s);
            }
            version.setSelectedItem(tempVer);
          }
          version.addActionListener(al);
        }
      } else {
        packPanels.get(i).setBackground(UIManager.getColor("control"));
        packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
    }
  }
Esempio n. 30
0
  /** Parse clicks to cancel the recording if we get a click that's not in the JList (or ESC). */
  protected boolean parseClick(AWTEvent event) {

    if (isFinished()) {
      return false;
    }

    // FIXME add key-based activation/termination?
    boolean consumed = true;
    if (combo == null) {
      combo = getComboBox(event);
      listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
              index = combo.getSelectedIndex();
              if (!combo.isPopupVisible()) {
                combo.removeActionListener(listener);
                setFinished(true);
              }
            }
          };
      combo.addActionListener(listener);
      setStatus("Waiting for selection");
    } else if (event.getID() == KeyEvent.KEY_RELEASED
        && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE
            || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) {
      index = combo.getSelectedIndex();
      setFinished(true);
    }
    // Cancel via click somewhere else
    else if (event.getID() == MouseEvent.MOUSE_PRESSED
        && !AWT.isOnPopup((Component) event.getSource())
        && combo != getComboBox(event)) {
      setFinished(true);
      consumed = false;
    }
    // Cancel via ESC key
    else if (event.getID() == KeyEvent.KEY_RELEASED
        && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ESCAPE) {
      setStatus("Selection canceled");
      setFinished(true);
    } else {
      Log.debug("Event ignored");
    }
    if (list == null && combo.isPopupVisible()) list = tester.findComboList(combo);

    if (isFinished()) {
      combo.removeActionListener(listener);
      listener = null;
    }

    return consumed;
  }