コード例 #1
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);
    }
コード例 #2
0
ファイル: ContextEditor.java プロジェクト: sillsdev/silkin
  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
コード例 #3
0
ファイル: Options.java プロジェクト: davidsawyer/VisualSort
  /*
  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);
  }
コード例 #4
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));
  }
コード例 #5
0
ファイル: SourcePanel.java プロジェクト: cecemel/Util
 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));
 }
コード例 #6
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);
  }
コード例 #7
0
ファイル: FileManager.java プロジェクト: argodev/BiLab
 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;
 }
コード例 #8
0
  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);
  }
コード例 #9
0
  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);
          }
        });
  }
コード例 #10
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);
 }
コード例 #11
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
  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
    }
  }
コード例 #12
0
ファイル: ComboBoxDemo2.java プロジェクト: aki-s/emacs.pub
  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
コード例 #13
0
ファイル: Controller.java プロジェクト: onyxbits/ScenePainter
 @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;
 }
コード例 #14
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;
  }
コード例 #15
0
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout2);
    formatPanel.setLayout(gridBagLayout1);
    formatPanel.setBorder(BorderFactory.createEtchedBorder());
    formatLabel.setText(I18N.get("datasource.DataSourceQueryChooserDialog.format"));
    formatComboBox.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            formatComboBox_actionPerformed(e);
          }
        });
    okCancelPanel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            okCancelPanel_actionPerformed(e);
          }
        });

    this.getContentPane().add(mainPanel, BorderLayout.NORTH);
    this.getContentPane().add(formatPanel, BorderLayout.CENTER);
    this.getContentPane().add(okCancelPanel, BorderLayout.SOUTH);
    formatPanel.add(
        formatComboBox,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(16, 4, 16, 4),
            0,
            0));
    formatPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(16, 4, 16, 4),
            0,
            0));
  }
コード例 #16
0
ファイル: AnimationWidget.java プロジェクト: nbearson/IDV
  /**
   * Contruct a new AnimationWidget.
   *
   * @param parentf the parent JFrame
   * @param anim a ucar.visad.display.Animation object to manage
   * @param info Default values for the AnimationInfo
   */
  public AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info) {

    // Initialize sharing to true
    super("AnimationWidget", true);
    timesCbx =
        new JComboBox() {
          public String getToolTipText(MouseEvent event) {
            if (boxPanel != null) {
              return boxPanel.getToolTipText();
            }
            return " ";
          }
        };
    timesCbx.setToolTipText("");
    timesCbxMutex = timesCbx.getTreeLock();
    timesCbx.setFont(new Font("Dialog", Font.PLAIN, 9));
    timesCbx.setLightWeightPopupEnabled(false);
    // set to non-visible until items are added
    timesCbx.setVisible(false);
    timesCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!ignoreTimesCbxEvents && (anime != null)) {
              debug("got timesCbx event");
              setTimeFromUser((Real) timesCbx.getSelectedItem());
              if (boxPanel != null) {
                boxPanel.setOnIndex(timesCbx.getSelectedIndex());
              }
            }
          }
        });

    animationInfo = new AnimationInfo();
    if (anim != null) {
      setAnimation(anim);
    }
    if (anime != null) {
      animationInfo.set(anime.getAnimationInfo());
    }
    if (info != null) {
      setProperties(info);
      animationInfo.setRunning(info.getRunning());
    }

    boxPanel = new AnimationBoxPanel(this);
    if (timesArray != null) {
      updateBoxPanel(timesArray);
    }
  }
コード例 #17
0
ファイル: BehaviorTree.java プロジェクト: northern-bites/tool
  private void setupWindowAndListeners() {
    // Initialize Objects
    title = new JLabel("Coordinated Behavior Tree", JLabel.CENTER);
    treeScroller = new JScrollPane();
    treeNodes = new Vector<PBTreeNode>();
    treeView = new JTree(treeNodes);
    stratView = new JList();
    formView = new JList();
    roleView = new JList();
    subRoleView = new JList();

    // Setup our display selection drop down list
    selectorList = new Vector<String>();
    selectorList.add(PBTREE_ID);
    selectorList.add(STRAT_ID);
    selectorList.add(FORM_ID);
    selectorList.add(ROLE_ID);
    selectorList.add(SUBROLE_ID);
    displaySelector = new JComboBox(selectorList);
    displaySelector.addActionListener(this);
    treeScroller.getViewport().setView(treeView);
    treeMode = PBTREE_ID;
    treeScroller.setFocusable(false);
    treeScroller.addMouseListener(this);
    subRoleView.addMouseListener(this);

    // Setup Layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);

    // Add Items
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(title, c);
    c.gridheight = 2;
    add(title);

    gridbag.setConstraints(displaySelector, c);
    add(displaySelector);

    c.gridheight = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(treeScroller, c);
    add(treeScroller);
  }
コード例 #18
0
ファイル: GUI.java プロジェクト: sametkaya/BLM305
  JPanel topPanel() {
    JPanel top = new JPanel();
    top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
    top.setBackground(COLOR);

    // menu.setFont(BOLD);
    menu.addActionListener(this);
    top.add(menu);

    top.add(Box.createHorizontalStrut(scaled(50)));
    top.add(Box.createHorizontalGlue());

    who.setFont(BOLD);
    who.setForeground(Color.black);
    top.add(who);

    return top;
  }
コード例 #19
0
  public void init() {
    // Set up the applet's GUI.  It consists of a canvas, or drawing area,
    // plus a row of controls below the canvas.  The controls include three
    // buttons which are used to add shapes to the canvas and a Choice menu
    // that is used to select the color used for a shape when it is created.
    // The canvas is set as the "listener" for these controls so that it can
    // respond to the user's actions.

    setBackground(Color.lightGray);

    ShapeCanvas canvas = new ShapeCanvas(); // create the canvas

    JComboBox colorChoice = new JComboBox(); // color choice menu
    colorChoice.addItem("Red");
    colorChoice.addItem("Green");
    colorChoice.addItem("Blue");
    colorChoice.addItem("Cyan");
    colorChoice.addItem("Magenta");
    colorChoice.addItem("Yellow");
    colorChoice.addItem("Black");
    colorChoice.addItem("White");
    colorChoice.addActionListener(canvas);

    JButton rectButton = new JButton("Rect"); // buttons for adding shapes
    rectButton.addActionListener(canvas);

    JButton ovalButton = new JButton("Oval");
    ovalButton.addActionListener(canvas);

    JButton roundRectButton = new JButton("RoundRect");
    roundRectButton.addActionListener(canvas);

    JPanel bottom = new JPanel(); // a Panel to hold the control buttons
    bottom.setLayout(new GridLayout(1, 4, 3, 3));
    bottom.add(rectButton);
    bottom.add(ovalButton);
    bottom.add(roundRectButton);
    bottom.add(colorChoice);

    getContentPane().setLayout(new BorderLayout(3, 3));
    getContentPane().add("Center", canvas); // add canvas and controls to the applet
    getContentPane().add("South", bottom);
  } // end init()
コード例 #20
0
  public FindProf() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Search your campus!");
    JLabel patternLabel2 = new JLabel("");

    patternList = new JComboBox<Object>(searchNames);
    patternList.setEditable(true);
    patternList.setMaximumRowCount(5);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setHorizontalAlignment(SwingConstants.CENTER);
    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));
  } // constructor
コード例 #21
0
  public AddColumnDialog(Frame owner, ArrayList<TableColumn> cols) {
    super(owner, true);
    this.cols = cols;
    this.setSize(300, 200);

    JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    for (int i = 0; i < cols.size(); i++) {
      box.addItem(cols.get(i).getName());
    }
    tc = cols.get(0);
    box.addActionListener(this);
    pane.add(box);
    JButton button = new JButton("Ok");
    button.addActionListener(this);
    pane.add(button);
    this.add(pane);
    this.setVisible(true);
  }
コード例 #22
0
ファイル: Animation.java プロジェクト: maeyler/Automata
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
コード例 #23
0
ファイル: BrowserFrame.java プロジェクト: haleyjd/Browsar
    protected void addMyControls() {
      // add browser-style control buttons
      JButton home = new JButton(new ImageIcon("data/Home24.gif"));
      JButton back = new JButton(new ImageIcon("data/Back24.gif"));
      JButton fwd = new JButton(new ImageIcon("data/Forward24.gif"));

      home.setToolTipText("Home");
      home.addActionListener(this);
      home.setActionCommand(homeCmd);

      back.setToolTipText("Back");
      back.addActionListener(this);
      back.setActionCommand(backCmd);
      back.setEnabled(false); // initially disabled

      fwd.setToolTipText("Forward");
      fwd.addActionListener(this);
      fwd.setActionCommand(forwardCmd);
      fwd.setEnabled(false); // initially disabled

      add(home);
      add(back);
      add(fwd);
      add(new JToolBar.Separator());

      // set built-in index variables
      homeIndex = getComponentIndex(home);
      backIndex = getComponentIndex(back);
      forwardIndex = getComponentIndex(fwd);

      JComboBox comboBox = new JComboBox();
      comboBox.setEditable(true);
      comboBox.addActionListener(this);
      comboBox.setActionCommand(comboCmd);
      comboBox.setMaximumRowCount(3); // don't let it get too long
      comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty

      add(comboBox);

      comboBoxIndex = getComponentIndex(comboBox);
    }
コード例 #24
0
  private void addEventListener() {
    btn.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH);
            String date = lastLabel.getText();
            String str2 = month + 1 + "";
            String str3 = date;
            if (month + 1 < 10) {
              str2 = "0" + (month + 1);
            }

            if (Integer.valueOf(date) < 10) {
              str3 = "0" + date;
            }
            text.setText(year + "-" + str2 + "-" + str3);
            MySimpleCal.this.dispose();
          }
        });

    monthBox.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            resetPanel();
          }
        });

    yearSpi.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            resetPanel();
          }
        });
  }
コード例 #25
0
    public ChoiceField(ChoiceOption option) {
      super(option);
      this.choices = option.getChoices().toArray(new Choice[0]);

      comboBox = new JComboBox();
      for (int i = 0; i < choices.length; i++) {
        comboBox.addItem(makeEntry(choices[i].getDisplayName()));
        if (i == 0 || choices[i].isDefault()) {
          comboBox.setSelectedIndex(i);
        }
      }
      comboBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              fireChangeEvent();
            }
          });

      configureEnableToggle(
          option.isInitiallyEnabled(),
          option.getDisabledValue(),
          Arrays.asList((JComponent) comboBox));
    }
コード例 #26
0
ファイル: Ladder.java プロジェクト: yblee/Ladder
  private void initStart() {
    // setResizable(false);
    setLayout(null);

    jlb = new JLabel("참여 인원수를 선택하세요");
    jlb.setBounds(7, 7, 160, 20);

    jcb = new JComboBox();
    for (int i = 2; i <= 10; i++) jcb.addItem(i);
    jcb.setSelectedItem(6);
    jcb.setMaximumRowCount(9);
    jcb.setBounds(50, 34, 70, 20);

    start_bt = new JButton("Start");
    start_bt.setBounds(45, 62, 80, 30);
    con.add(jlb);
    con.add(start_bt);
    con.add(jcb);

    start_bt.addActionListener(this);
    jcb.addActionListener(this);

    setVisible(true);
  }
コード例 #27
0
ファイル: ComboBoxes.java プロジェクト: git263/letscode
 public ComboBoxes() {
   for (int i = 0; i < 4; i++) c.addItem(description[count++]);
   t.setEditable(false);
   b.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           if (count < description.length) c.addItem(description[count++]);
         }
       });
   c.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           t.setText(
               "index: "
                   + c.getSelectedIndex()
                   + "   "
                   + ((JComboBox) e.getSource()).getSelectedItem());
         }
       });
   setLayout(new FlowLayout());
   add(t);
   add(c);
   add(b);
 }
コード例 #28
0
ファイル: Shapes.java プロジェクト: syzh1991/DigitalEarth
    private JPanel makeInteriorAttributesPanel() {
      JPanel outerPanel = new JPanel(new BorderLayout(6, 6));
      outerPanel.setBorder(this.createTitleBorder("Surface Attributes"));

      GridLayout nameLayout = new GridLayout(0, 1, 6, 6);
      JPanel namePanel = new JPanel(nameLayout);

      GridLayout valueLayout = new GridLayout(0, 1, 6, 6);
      JPanel valuePanel = new JPanel(valueLayout);

      namePanel.add(new JLabel("Style"));
      final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid"});
      cb1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentInteriorStyle = (String) cb1.getSelectedItem();
              update();
            }
          });
      cb1.setSelectedItem("Solid");
      valuePanel.add(cb1);

      namePanel.add(new JLabel("Opacity"));
      JSpinner sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentInteriorOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      namePanel.add(new JLabel("Color"));
      final JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb2.setSelectedItem(currentInteriorColor);
      cb2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentInteriorColor =
                  (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb2);

      namePanel.add(new JLabel("Border"));
      final JComboBox cb5 = new JComboBox(new String[] {"None", "Solid"});
      cb5.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentBorderStyle = (String) cb5.getSelectedItem();
              update();
            }
          });
      cb5.setSelectedItem("Solid");
      valuePanel.add(cb5);

      namePanel.add(new JLabel("Border Width"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentBorderWidth, 1d, 10d, 1d));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentBorderWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      sp.setValue(currentBorderWidth);
      valuePanel.add(sp);

      namePanel.add(new JLabel("Border Color"));
      JComboBox cb4 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb4.setSelectedItem(currentBorderColor);
      cb4.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentBorderColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb4);

      namePanel.add(new JLabel("Border Opacity"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentBorderOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      outerPanel.add(namePanel, BorderLayout.WEST);
      outerPanel.add(valuePanel, BorderLayout.CENTER);

      return outerPanel;
    }
コード例 #29
0
ファイル: Shapes.java プロジェクト: syzh1991/DigitalEarth
    private JPanel makePathAttributesPanel() {
      JPanel outerPanel = new JPanel(new BorderLayout(6, 6));
      outerPanel.setBorder(this.createTitleBorder("Path Attributes"));

      GridLayout nameLayout = new GridLayout(0, 1, 6, 6);
      JPanel namePanel = new JPanel(nameLayout);

      GridLayout valueLayout = new GridLayout(0, 1, 6, 6);
      JPanel valuePanel = new JPanel(valueLayout);

      namePanel.add(new JLabel("Follow Terrain"));
      JCheckBox ckb = new JCheckBox();
      ckb.setSelected(currentFollowTerrain);
      ckb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentFollowTerrain = ((JCheckBox) actionEvent.getSource()).isSelected();
              update();
            }
          });
      valuePanel.add(ckb);

      JLabel label;

      namePanel.add(label = new JLabel("Conformance"));
      int[] values = new int[] {1, 2, 4, 8, 10, 15, 20, 30, 40, 50};
      String[] strings = new String[values.length];
      for (int i = 0; i < values.length; i++) {
        strings[i] = Integer.toString(values[i]) + " pixels";
      }
      JSpinner sp = new JSpinner(new SpinnerListModel(strings));
      onTerrainOnlyItems.add(label);
      onTerrainOnlyItems.add(sp);
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              String v = (String) ((JSpinner) changeEvent.getSource()).getValue();
              currentTerrainConformance = Integer.parseInt(v.substring(0, v.indexOf(" ")));
              update();
            }
          });
      sp.setValue(Integer.toString(currentTerrainConformance) + " pixels");
      valuePanel.add(sp);

      namePanel.add(label = new JLabel("Subsegments"));
      sp = new JSpinner(new SpinnerListModel(new String[] {"1", "2", "5", "10", "20", "40", "50"}));
      offTerrainOnlyItems.add(label);
      offTerrainOnlyItems.add(sp);
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              String v = (String) ((JSpinner) changeEvent.getSource()).getValue();
              currentNumSubsegments = Integer.parseInt(v);
              update();
            }
          });
      sp.setValue(Integer.toString(currentNumSubsegments));
      valuePanel.add(sp);

      namePanel.add(new JLabel("Type"));
      final JComboBox cb = new JComboBox(new String[] {"Great Circle", "Linear", "Rhumb Line"});
      cb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathType = (String) cb.getSelectedItem();
              update();
            }
          });
      cb.setSelectedItem("Great Circle");
      valuePanel.add(cb);

      namePanel.add(new JLabel("Style"));
      final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid", "Dash"});
      cb1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathStyle = (String) cb1.getSelectedItem();
              update();
            }
          });
      cb1.setSelectedItem("Solid");
      valuePanel.add(cb1);

      namePanel.add(new JLabel("Width"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentPathWidth, 1d, 10d, 1d));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentPathWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      sp.setValue(currentPathWidth);
      valuePanel.add(sp);

      namePanel.add(new JLabel("Color"));
      JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb2.setSelectedItem(currentPathColor);
      cb2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb2);

      namePanel.add(new JLabel("Opacity"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentPathOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentPathOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      namePanel.add(new JLabel("Offset"));
      sp =
          new JSpinner(
              new SpinnerListModel(
                  new String[] {"0", "10", "100", "1000", "10000", "100000", "1000000"}));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentOffset =
                  Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue());
              update();
            }
          });
      sp.setValue("0");
      valuePanel.add(sp);

      outerPanel.add(namePanel, BorderLayout.WEST);
      outerPanel.add(valuePanel, BorderLayout.CENTER);

      return outerPanel;
    }
コード例 #30
0
  /**
   * Create a choicebox for link line style options and return the panel it is in.
   *
   * @return JPanel the panel holding the new choicebox for the link style options.
   */
  private JPanel createLinkDashedChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbLinkDashed = new JComboBox();
    cbLinkDashed.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$
    cbLinkDashed.setOpaque(true);
    cbLinkDashed.setEditable(false);
    cbLinkDashed.setEnabled(false);
    cbLinkDashed.setMaximumRowCount(10);
    cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$

    cbLinkDashed.validate();

    cbLinkDashed.setSelectedIndex(0);

    DefaultListCellRenderer drawRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (list != null) {
              if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
              } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
              }
            }

            setText((String) value);
            return this;
          }
        };

    cbLinkDashed.setRenderer(drawRenderer);

    ActionListener drawActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateLinkDashed(cbLinkDashed.getSelectedIndex());
          }
        };
    cbLinkDashed.addActionListener(drawActionListener);

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbLinkDashed, BorderLayout.CENTER);
    return drawPanel;
  }