예제 #1
0
  private int checkSetSizesFromParent(Container container, Insets insets) {
    int skipLayout = 0;
    GridLayoutManager parentGridLayout = null;
    GridConstraints parentGridConstraints = null;
    Container parent = container.getParent();
    if (parent != null) {
      if (parent.getLayout() instanceof GridLayoutManager) {
        parentGridLayout = (GridLayoutManager) parent.getLayout();
        parentGridConstraints = parentGridLayout.getConstraintsForComponent(container);
      } else {
        Container col = parent.getParent();
        if (col != null && col.getLayout() instanceof GridLayoutManager) {
          parentGridLayout = (GridLayoutManager) col.getLayout();
          parentGridConstraints = parentGridLayout.getConstraintsForComponent(parent);
        }
      }
    }

    if (parentGridLayout != null && parentGridConstraints.isUseParentLayout()) {
      int i;
      if (this.myRowStretches.length == parentGridConstraints.getRowSpan()) {
        int row = parentGridConstraints.getRow();
        this.myYs[0] = insets.top + this.myMargin.top;
        this.myHeights[0] = parentGridLayout.myHeights[row] - this.myYs[0];

        for (i = 1; i < this.myRowStretches.length; ++i) {
          this.myYs[i] = parentGridLayout.myYs[i + row] - parentGridLayout.myYs[row];
          this.myHeights[i] = parentGridLayout.myHeights[i + row];
        }

        this.myHeights[this.myRowStretches.length - 1] -= insets.bottom + this.myMargin.bottom;
        skipLayout |= 1;
      }

      if (this.myColumnStretches.length == parentGridConstraints.getColSpan()) {
        int column = parentGridConstraints.getColumn();
        this.myXs[0] = insets.left + this.myMargin.left;
        this.myWidths[0] = parentGridLayout.myWidths[column] - this.myXs[0];

        for (i = 1; i < this.myColumnStretches.length; ++i) {
          this.myXs[i] = parentGridLayout.myXs[i + column] - parentGridLayout.myXs[column];
          this.myWidths[i] = parentGridLayout.myWidths[i + column];
        }

        this.myWidths[this.myColumnStretches.length - 1] -= insets.right + this.myMargin.right;
        skipLayout |= 2;
      }
    }

    return skipLayout;
  }
예제 #2
0
 private static void updateSizesFromChildren(DimensionInfo info, boolean min, int[] widths) {
   for (int i = info.getComponentCount() - 1; i >= 0; --i) {
     Component child = info.getComponent(i);
     GridConstraints c = info.getConstraints(i);
     if (c.isUseParentLayout() && child instanceof Container) {
       Container container = (Container) child;
       if (container.getLayout() instanceof GridLayoutManager) {
         updateSizesFromChild(info, min, widths, container, i);
       } else if (container.getComponentCount() == 1
           && container.getComponent(0) instanceof Container) {
         Container childContainer = (Container) container.getComponent(0);
         if (childContainer.getLayout() instanceof GridLayoutManager) {
           updateSizesFromChild(info, min, widths, childContainer, i);
         }
       }
     }
   }
 }
예제 #3
0
  /**
   * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a
   * grid. Each component in a column is as wide as the maximum preferred width of the components in
   * that column; height is similarly determined for each row. The parent is made just big enough to
   * fit them all.
   *
   * @param rows number of rows
   * @param cols number of columns
   * @param initialX x location to start the grid at
   * @param initialY y location to start the grid at
   * @param xPad x padding between cells
   * @param yPad y padding between cells
   */
  public static void makeCompactGrid(
      Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
    SpringLayout layout;
    try {
      layout = (SpringLayout) parent.getLayout();
    } catch (ClassCastException exc) {
      // System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
      logger.log("The first argument to makeCompactGrid must use SpringLayout." + exc);
      return;
    }

    // Align all cells in each column and make them the same width.
    Spring x = Spring.constant(initialX);
    for (int c = 0; c < cols; c++) {
      Spring width = Spring.constant(0);
      for (int r = 0; r < rows; r++) {
        width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
      }
      for (int r = 0; r < rows; r++) {
        SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
        constraints.setX(x);
        constraints.setWidth(width);
      }
      x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
    }

    // Align all cells in each row and make them the same height.
    Spring y = Spring.constant(initialY);
    for (int r = 0; r < rows; r++) {
      Spring height = Spring.constant(0);
      for (int c = 0; c < cols; c++) {
        height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
      }
      for (int c = 0; c < cols; c++) {
        SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
        constraints.setY(y);
        constraints.setHeight(height);
      }
      y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
    }

    // Set the parent's size.
    SpringLayout.Constraints pCons = layout.getConstraints(parent);
    pCons.setConstraint(SpringLayout.SOUTH, y);
    pCons.setConstraint(SpringLayout.EAST, x);
  }
예제 #4
0
  private static void updateSizesFromChild(
      DimensionInfo info, boolean min, int[] widths, Container container, int childIndex) {
    GridLayoutManager childLayout = (GridLayoutManager) container.getLayout();
    if (info.getSpan(childIndex) == info.getChildLayoutCellCount(childLayout)) {
      childLayout.validateInfos(container);
      DimensionInfo childInfo =
          info instanceof HorizontalInfo
              ? childLayout.myHorizontalInfo
              : childLayout.myVerticalInfo;
      int[] sizes = childLayout.getMinOrPrefSizes(childInfo, min);
      int cell = info.getCell(childIndex);

      for (int j = 0; j < sizes.length; ++j) {
        widths[cell + j] = Math.max(widths[cell + j], sizes[j]);
      }
    }
  }
  /**
   * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a
   * grid. Each component is as big as the maximum preferred width and height of the components. The
   * parent is made just big enough to fit them all.
   *
   * @param rows number of rows
   * @param cols number of columns
   * @param initialX x location to start the grid at
   * @param initialY y location to start the grid at
   * @param xPad x padding between cells
   * @param yPad y padding between cells
   */
  public static void makeGrid(
      Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
    SpringLayout layout;
    try {
      layout = (SpringLayout) parent.getLayout();
    } catch (ClassCastException exc) {
      System.err.println("The first argument to makeGrid must use SpringLayout.");
      return;
    }

    Spring xPadSpring = Spring.constant(xPad);
    Spring yPadSpring = Spring.constant(yPad);
    Spring initialXSpring = Spring.constant(initialX);
    Spring initialYSpring = Spring.constant(initialY);
    int max = rows * cols;

    // Calculate Springs that are the max of the width/height so that all
    // cells have the same size.
    Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    for (int i = 1; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
      maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
    }

    // Apply the new width/height Spring. This forces all the
    // components to have the same size.
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      cons.setWidth(maxWidthSpring);
      cons.setHeight(maxHeightSpring);
    }

    // Then adjust the x/y constraints of all the cells so that they
    // are aligned in a grid.
    SpringLayout.Constraints lastCons = null;
    SpringLayout.Constraints lastRowCons = null;
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
      if (i % cols == 0) { // start of new row
        lastRowCons = lastCons;
        cons.setX(initialXSpring);
      } else { // x position depends on previous component
        cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
      }

      if (i / cols == 0) { // first row
        cons.setY(initialYSpring);
      } else { // y position depends on previous row
        cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
      }
      lastCons = cons;
    }

    // Set the parent's size.
    SpringLayout.Constraints pCons = layout.getConstraints(parent);
    pCons.setConstraint(
        SpringLayout.SOUTH,
        Spring.sum(Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
    pCons.setConstraint(
        SpringLayout.EAST,
        Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
  }
 /* Used by makeCompactGrid. */
 private static SpringLayout.Constraints getConstraintsForCell(
     int row, int col, Container parent, int cols) {
   SpringLayout layout = (SpringLayout) parent.getLayout();
   Component c = parent.getComponent(row * cols + col);
   return layout.getConstraints(c);
 }
예제 #7
0
  /**
   * Creates the appropriate object to represent each of the objects in <code>buttons</code> and
   * adds it to <code>container</code>. This differs from addMessageComponents in that it will
   * recurse on <code>buttons</code> and that if button is not a Component it will create an
   * instance of JButton.
   */
  protected void addButtonComponents(Container container, Object[] buttons, int initialIndex) {
    if (buttons != null && buttons.length > 0) {
      boolean sizeButtonsToSame = getSizeButtonsToSameWidth();
      boolean createdAll = true;
      int numButtons = buttons.length;
      JButton[] createdButtons = null;
      int maxWidth = 0;

      if (sizeButtonsToSame) {
        createdButtons = new JButton[numButtons];
      }

      for (int counter = 0; counter < numButtons; counter++) {
        Object button = buttons[counter];
        Component newComponent;

        if (button instanceof Component) {
          createdAll = false;
          newComponent = (Component) button;
          container.add(newComponent);
          hasCustomComponents = true;

        } else {
          JButton aButton;

          if (button instanceof ButtonFactory) {
            aButton = ((ButtonFactory) button).createButton();
          } else if (button instanceof Icon) aButton = new JButton((Icon) button);
          else aButton = new JButton(button.toString());

          aButton.setName("OptionPane.button");
          aButton.setMultiClickThreshhold(
              DefaultLookup.getInt(optionPane, this, "OptionPane.buttonClickThreshhold", 0));
          configureButton(aButton);

          container.add(aButton);

          ActionListener buttonListener = createButtonActionListener(counter);
          if (buttonListener != null) {
            aButton.addActionListener(buttonListener);
          }
          newComponent = aButton;
        }
        if (sizeButtonsToSame && createdAll && (newComponent instanceof JButton)) {
          createdButtons[counter] = (JButton) newComponent;
          maxWidth = Math.max(maxWidth, newComponent.getMinimumSize().width);
        }
        if (counter == initialIndex) {
          initialFocusComponent = newComponent;
          if (initialFocusComponent instanceof JButton) {
            JButton defaultB = (JButton) initialFocusComponent;
            defaultB.addHierarchyListener(
                new HierarchyListener() {
                  public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) {
                      JButton defaultButton = (JButton) e.getComponent();
                      JRootPane root = SwingUtilities.getRootPane(defaultButton);
                      if (root != null) {
                        root.setDefaultButton(defaultButton);
                      }
                    }
                  }
                });
          }
        }
      }
      ((ButtonAreaLayout) container.getLayout())
          .setSyncAllWidths((sizeButtonsToSame && createdAll));
      /* Set the padding, windows seems to use 8 if <= 2 components,
      otherwise 4 is used. It may actually just be the size of the
      buttons is always the same, not sure. */
      if (DefaultLookup.getBoolean(optionPane, this, "OptionPane.setButtonMargin", true)
          && sizeButtonsToSame
          && createdAll) {
        JButton aButton;
        int padSize;

        padSize = (numButtons <= 2 ? 8 : 4);

        for (int counter = 0; counter < numButtons; counter++) {
          aButton = createdButtons[counter];
          aButton.setMargin(new Insets(2, padSize, 2, padSize));
        }
      }
    }
  }
예제 #8
0
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Darya Koreneva
    scrollPane1 = new JScrollPane();
    userTable = new JTable();
    newUserNameLabel = new JLabel();
    newUserNameTextField = new JTextField();
    addButton = new JButton();
    cancelButton = new JButton();
    addUserButton = new JButton();
    deleteUserButton = new JButton();
    blockButton = new JButton();
    unblockButton = new JButton();

    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights =
        new double[] {1.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 0.0, 1.0E-4};

    // ======== scrollPane1 ========
    {
      scrollPane1.setViewportView(userTable);
    }
    contentPane.add(
        scrollPane1,
        new GridBagConstraints(
            0,
            0,
            5,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    // ---- newUserNameLabel ----
    newUserNameLabel.setText("New user name:");
    newUserNameLabel.setVisible(false);
    newUserNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(
        newUserNameLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- newUserNameTextField ----
    newUserNameTextField.setVisible(false);
    contentPane.add(
        newUserNameTextField,
        new GridBagConstraints(
            1,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- addButton ----
    addButton.setText("Add");
    addButton.setVisible(false);
    contentPane.add(
        addButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5),
            0,
            0));

    // ---- cancelButton ----
    cancelButton.setText("Cancel");
    cancelButton.setVisible(false);
    contentPane.add(
        cancelButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    // ---- addUserButton ----
    addUserButton.setText("Add user");
    contentPane.add(
        addUserButton,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- deleteUserButton ----
    deleteUserButton.setText("Delete user");
    contentPane.add(
        deleteUserButton,
        new GridBagConstraints(
            2,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- blockButton ----
    blockButton.setText("Block");
    contentPane.add(
        blockButton,
        new GridBagConstraints(
            3,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5),
            0,
            0));

    // ---- unblockButton ----
    unblockButton.setText("Unblock");
    contentPane.add(
        unblockButton,
        new GridBagConstraints(
            4,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    setSize(560, 335);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents

    setData(sys.userMap);
    addUserButton.addActionListener(
        (v) -> {
          newUserNameLabel.setVisible(true);
          newUserNameTextField.setVisible(true);
          addButton.setVisible(true);
          cancelButton.setVisible(true);
        });
    addButton.addActionListener(
        (v) -> {
          String newUserName = newUserNameTextField.getText();
          sys.userMap.put(newUserName, new User(newUserName, ""));
          setData(sys.userMap);
          newUserNameLabel.setVisible(false);
          newUserNameTextField.setVisible(false);
          addButton.setVisible(false);
          cancelButton.setVisible(false);
        });
    cancelButton.addActionListener(
        (v) -> {
          newUserNameLabel.setVisible(false);
          newUserNameTextField.setVisible(false);
          addButton.setVisible(false);
          cancelButton.setVisible(false);
        });
    deleteUserButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          sys.userMap.remove(valueAt);
          setData(sys.userMap);
        });
    blockButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          User user = sys.getUserByName(valueAt.toString());
          user.setBlocked(true);
          setData(sys.userMap);
        });
    unblockButton.addActionListener(
        (v) -> {
          Object valueAt =
              userTable.getValueAt(userTable.getSelectedRow(), userTable.getSelectedColumn());
          User user = sys.getUserByName(valueAt.toString());
          user.setBlocked(false);
          setData(sys.userMap);
        });
  }
예제 #9
0
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }