Ejemplo n.º 1
0
 public void addRadioButton(String name, SongLooper sl, MIDIPlayer p) {
   LoopRadioButton b = new LoopRadioButton(name, sl, p);
   add(b);
   bg.add(b);
   if (bg.getButtonCount() == selIndex) {
     b.setSelected(true);
   }
 }
Ejemplo n.º 2
0
 public static void clearButtonGroup(ButtonGroup g) {
   if (g == null || g.getButtonCount() == 0) return;
   Enumeration e = g.getElements();
   List<AbstractButton> list = new ArrayList<AbstractButton>();
   while (e.hasMoreElements()) list.add((AbstractButton) e.nextElement());
   for (AbstractButton b : list) {
     g.remove(b);
   }
 }
Ejemplo n.º 3
0
 /**
  * Adds a radio button to select an algorithm.
  *
  * @param c the container into which to place the button
  * @param name the algorithm name
  * @param g the button group
  */
 public void addRadioButton(Container c, final String name, ButtonGroup g) {
   ActionListener listener =
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           setAlgorithm(name);
         }
       };
   JRadioButton b = new JRadioButton(name, g.getButtonCount() == 0);
   c.add(b);
   g.add(b);
   b.addActionListener(listener);
 }
Ejemplo n.º 4
0
 public MainPanel() {
   super(new BorderLayout());
   BufferedImage bi = null;
   try {
     bi = ImageIO.read(getClass().getResource("test.jpg"));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
   bufferedImage = bi;
   List<AbstractAction> list =
       Arrays.asList(
           new AbstractAction("NONE") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.NONE;
               repaint();
             }
           },
           new AbstractAction("VERTICAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.VERTICAL;
               repaint();
             }
           },
           new AbstractAction("HORIZONTAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.HORIZONTAL;
               repaint();
             }
           });
   Box box = Box.createHorizontalBox();
   box.add(Box.createHorizontalGlue());
   box.add(new JLabel("Flip: "));
   for (AbstractAction a : list) {
     JRadioButton rb = new JRadioButton(a);
     if (bg.getButtonCount() == 0) {
       rb.setSelected(true);
     }
     box.add(rb);
     bg.add(rb);
     box.add(Box.createHorizontalStrut(5));
   }
   add(p);
   add(box, BorderLayout.SOUTH);
   setOpaque(false);
   setPreferredSize(new Dimension(320, 240));
 }
  /** grouping PKCS7-[XXX]-[XXX] files */
  private boolean _addGroup() {
    String strMethod = "_addGroup()";

    // adding radioButtons/labelChecks for selecting in between JAR, and JHR, and RCR files

    if (this._btnTypeFileShkDer == null) {
      MySystem.s_printOutError(this, strMethod, "nil this._btnTypeFileShk[xxx]");
      return false;
    }

    // ----

    ButtonGroup bgp = new ButtonGroup();
    // bgp.add(this._btnTypeFileShkPkcs7);

    if (this._btnTypeFileShkPem != null) bgp.add(this._btnTypeFileShkPem);

    bgp.add(this._btnTypeFileShkDer);

    if (bgp.getButtonCount() < 2) {
      this._btnTypeFileShkDer.setEnabled(false);
    }

    // selecting first button
    this._btnTypeFileShkDer.setSelected(true);

    // else label: done at construction time

    // --
    JPanel pnlTypeFileShk = new JPanel();
    pnlTypeFileShk.setLayout(new BoxLayout(pnlTypeFileShk, BoxLayout.Y_AXIS));
    pnlTypeFileShk.add(this._btnTypeFileShkDer); // default

    if (this._btnTypeFileShkPem != null) pnlTypeFileShk.add(this._btnTypeFileShkPem);

    // --
    if (super._pnl_ == null) {
      MySystem.s_printOutError(this, strMethod, "nil super._pnl_");
      return false;
    }

    super._pnl_.add(pnlTypeFileShk);

    // ending
    return true;
  }
Ejemplo n.º 6
0
  /**
   * Crée et renvoie le panneau de sprites
   *
   * @return Le panel contenant les sprites
   */
  public JPanel createSpritesPanel() {
    panneauSprites.setLayout(new GridBagLayout());
    panneauSprites.add(
        sprites,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    // Création de l'affichage des sprites

    // sprites.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    layoutSprites = new GridLayout();
    layoutSprites.setHgap(0);
    layoutSprites.setVgap(0);
    sprites.setLayout(layoutSprites);
    if (groupe.getButtonCount() <= 0) {
      System.err.println(
          "Erreur dans Selection.Selection(int lc, "
              + "int hc) : pas de dossiers dans le dossier images.");
    } else {
      ((JRadioButton) categories.getComponent(0)).setSelected(true);
      this.afficherSprites(
          new File("images/" + ((JRadioButton) categories.getComponent(0)).getText()));
    }

    // sprites.setLayout(new GridLayout(nbrSprites/nbrColonnes, nbrColonnes,
    // 0, 0));
    repaint();
    return panneauSprites;
  }
Ejemplo n.º 7
0
  public NewDetailsPanel() {
    for (int i = 0; i < Array.getLength(overallRadioButtons); i++) {
      rgOverall.add(overallRadioButtons[i]);
    }
    for (int i = 0; i < Array.getLength(priceRadioButtons); i++) {
      rgPrice.add(priceRadioButtons[i]);
    }
    for (int i = 0; i < Array.getLength(foodRadioButtons); i++) {
      rgFood.add(foodRadioButtons[i]);
    }
    for (int i = 0; i < Array.getLength(serviceRadioButtons); i++) {
      rgService.add(serviceRadioButtons[i]);
    }
    layout = new GridBagLayout();
    this.setLayout(layout);
    constraints = new GridBagConstraints();

    constraints.fill = (GridBagConstraints.BOTH);
    //        addComponent(name, 0, 0, 8, 1);
    //        addComponent(tfName, 0, 2, 8, 1);
    //        addComponent(address, 1, 0, 2, 1);
    //        addComponent(tfAddress, 1, 2, 8, 1);
    //        addComponent(city, 2, 0, 2, 1);
    //        addComponent(tfCity, 2, 2, 8, 1);
    //        addComponent(state, 3, 0, 2, 1);
    //        addComponent(tfState, 3, 2, 8, 1);
    //        addComponent(zip, 4, 0, 2, 1);
    //        addComponent(tfZip, 4, 2, 8, 1);
    //        addComponent(phone, 5, 0, 2, 1);
    //        addComponent(tfPhone, 5, 2, 8, 1);
    int row = 0;
    addComponent(name, row++, 0, 8, 1);
    addComponent(tfName, row++, 0, 8, 1);
    addComponent(address, row++, 0, 2, 1);
    addComponent(tfAddress, row++, 0, 8, 1);
    addComponent(city, row++, 0, 2, 1);
    addComponent(tfCity, row++, 0, 8, 1);
    addComponent(state, row++, 0, 2, 1);
    addComponent(tfState, row++, 0, 2, 1);
    addComponent(zip, row++, 0, 2, 1);
    addComponent(tfZip, row++, 0, 2, 1);
    addComponent(phone, row++, 0, 10, 1);
    addComponent(tfPhone, row++, 0, 2, 1);
    addComponent(webURL, row++, 0, 10, 1);
    addComponent(tfWebURL, row++, 0, 10, 1);
    addComponent(foodType, row++, 0, 10, 1);
    addComponent(tfFoodType, row++, 0, 10, 1);
    addComponent(overall, row++, 0, 2, 1);
    for (int i = 0; i < rgOverall.getButtonCount(); i++) {
      addComponent(overallRadioButtons[i], row, i * 2, 2, 1);
    }
    row++;
    addComponent(price, row++, 0, 2, 1);
    for (int i = 0; i < rgPrice.getButtonCount(); i++) {
      addComponent(priceRadioButtons[i], row, i * 2, 2, 1);
    }
    row++;
    addComponent(foodRating, row++, 0, 10, 1);
    for (int i = 0; i < rgFood.getButtonCount(); i++) {
      addComponent(foodRadioButtons[i], row, i * 2, 2, 1);
    }
    row++;
    addComponent(serviceRating, row++, 0, 10, 1);
    for (int i = 0; i < rgService.getButtonCount(); i++) {
      addComponent(serviceRadioButtons[i], row, i * 2, 2, 1);
    }
    row++;
    addComponent(comments, row++, 0, 2, 1);
    addComponent(taComments, row++, 0, 10, 10);
    this.setVisible(true);
  }
Ejemplo n.º 8
0
 public int getButtonCount() {
   return bg.getButtonCount();
 }
Ejemplo n.º 9
0
  public SizeChooser() {

    startWin = new JPanel();
    this.setDefaultCloseOperation(HIDE_ON_CLOSE);
    this.setVisible(true);

    // Next five uncommented lines tell it to be centered on the screen, since
    // this.setRelativeTo(null);
    // is really bad at that for these windows for whatever reason
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dim = tk.getScreenSize();
    int xPos = (dim.width / 2) - (this.getWidth() / 2) - 100;
    int yPos = (dim.height / 2) - (this.getHeight() / 2);
    this.setLocation(xPos, yPos); // Puts it in the middle of the screen

    ButtonGroup operation =
        new ButtonGroup(); // Makes a buttongroup so that only one of the radiobuttons can be
    // selected at a time

    // ========================================
    // ======== Button Initialization =========
    // ========================================

    size14 = new JRadioButton("Map size of 14x14");
    operation.add(size14);
    startWin.add(size14);
    size14.setSelected(true);

    size19 = new JRadioButton("Map size of 19x19");
    operation.add(size19);
    startWin.add(size19);

    size20 = new JRadioButton("Map size of 20x20");
    operation.add(size20);
    startWin.add(size20);

    size21 = new JRadioButton("Map size of 21x21");
    operation.add(size21);
    startWin.add(size21);

    size27 = new JRadioButton("Map size of 27x27");
    operation.add(size27);
    startWin.add(size27);

    size28 = new JRadioButton("Map size of 28x28");
    operation.add(size28);
    startWin.add(size28);

    size29 = new JRadioButton("Map size of 29x29");
    operation.add(size29);
    startWin.add(size29);

    size30 = new JRadioButton("Map size of 30x30");
    operation.add(size30);
    startWin.add(size30);

    OldMaze.numOfSizes = operation.getButtonCount();

    start = new JButton("Start");
    startWin.add(start);
    start.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitActionPerformed(evt);
          }
        });

    buttonNum = operation.getButtonCount();

    startWin.setLayout(new GridLayout(buttonNum + 1, 1));

    this.add(startWin);
  }