コード例 #1
0
  /** If Certificate was not accepted during installation user must accept it here. */
  public static boolean acceptCertificatePanel(String certificate) throws Exception {
    CertificatePanel CertificatePanel = new CertificatePanel(certificate);
    ResourceBundle bundle = NbBundle.getBundle(AcceptCertificate.class);
    String yesLabel = bundle.getString("MSG_CertificateYesButton");
    String noLabel = bundle.getString("MSG_CertificateNoButton");
    JButton yesButton = new JButton(yesLabel);
    JButton noButton = new JButton(noLabel);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            command = e.getActionCommand();
            d.setVisible(false);
          }
        };
    yesButton.addActionListener(listener);
    noButton.addActionListener(listener);

    yesButton.setActionCommand("yes"); // NOI18N
    noButton.setActionCommand("no"); // NOI18N

    yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_AcceptButton"));
    yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_AcceptButton"));

    noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_RejectButton"));
    noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_RejectButton"));

    int maxWidth = Math.max(yesButton.getPreferredSize().width, noButton.getPreferredSize().width);
    int maxHeight =
        Math.max(yesButton.getPreferredSize().height, noButton.getPreferredSize().height);
    yesButton.setPreferredSize(new Dimension(maxWidth, maxHeight));
    noButton.setPreferredSize(new Dimension(maxWidth, maxHeight));

    d = new JDialog((Frame) null, bundle.getString("MSG_CertificateDlgTitle"), true);

    d.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_CertificateDlg"));
    d.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CertificateDlg"));

    d.getContentPane().add(CertificatePanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(17, 12, 11, 11));
    buttonPanel.add(yesButton);
    buttonPanel.add(noButton);
    d.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    d.setSize(new Dimension(600, 600));
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setModal(true);
    d.setResizable(true);
    // Center on screen
    d.setLocationRelativeTo(null);
    d.setVisible(true);

    if ("yes".equals(command)) { // NOI18N
      return true;
    } else {
      return false;
    }
  }