private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) {
    lastAddedButton = button;

    constraints.insets = new Insets(0, 0, V_GAP, 0);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = gridX;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    this.add(button, constraints);

    int yBounds =
        TOP_BORDER
            + BOTTOM_BORDER
            + 2 * V_GAP
            + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height
            + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText())
                .height;

    button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT);

    button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    setButtonBg(button, gridX, isLast);

    return button.getWidth();
  }
예제 #2
0
 /**
  * After XMLEncoding the handler has gone. Here we explicitly use
  * JTextComponent.installDefaultTransferHandlerIfNecessary() to put one (back) in.
  *
  * @param comps
  */
 public static void fixCopyPasteBug(JComponent comps[]) {
   for (int i = 0; i < comps.length; i++) {
     JComponent comp = comps[i];
     List recursedControls = ComponentUtils.getAllControls(comp);
     for (Iterator iterator = recursedControls.iterator(); iterator.hasNext(); ) {
       Component component = (Component) iterator.next();
       if (component instanceof JComponent) {
         ComponentUtils.fixCopyPasteBug((JComponent) component);
       }
     }
   }
 }