1 19 20 package org.netbeans.modules.j2ee.sun.bridge; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Dimension ; 24 import java.awt.FlowLayout ; 25 import java.awt.Frame ; 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 import java.util.ResourceBundle ; 29 import javax.swing.BorderFactory ; 30 import javax.swing.JButton ; 31 import javax.swing.JDialog ; 32 import javax.swing.JPanel ; 33 34 import org.openide.util.NbBundle; 35 41 42 public final class AcceptCertificate { 43 44 private static JDialog d; 45 private static String command; 46 47 49 public static boolean acceptCertificatePanel (String certificate) throws Exception { 50 CertificatePanel CertificatePanel = new CertificatePanel(certificate); 51 ResourceBundle bundle = NbBundle.getBundle(AcceptCertificate.class); 52 String yesLabel = bundle.getString("MSG_CertificateYesButton"); 53 String noLabel = bundle.getString("MSG_CertificateNoButton"); 54 JButton yesButton = new JButton (yesLabel); 55 JButton noButton = new JButton (noLabel); 56 57 ActionListener listener = new ActionListener () { 58 public void actionPerformed (ActionEvent e) { 59 command = e.getActionCommand(); 60 d.setVisible(false); 61 } 62 }; 63 yesButton.addActionListener(listener); 64 noButton.addActionListener(listener); 65 66 yesButton.setActionCommand("yes"); noButton.setActionCommand("no"); 69 yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_AcceptButton")); 70 yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_AcceptButton")); 71 72 noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_RejectButton")); 73 noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_RejectButton")); 74 75 int maxWidth = Math.max(yesButton.getPreferredSize().width, noButton.getPreferredSize().width); 76 int maxHeight = Math.max(yesButton.getPreferredSize().height, noButton.getPreferredSize().height); 77 yesButton.setPreferredSize(new Dimension (maxWidth, maxHeight)); 78 noButton.setPreferredSize(new Dimension (maxWidth, maxHeight)); 79 80 d = new JDialog ((Frame ) null,bundle.getString("MSG_CertificateDlgTitle"),true); 81 82 d.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_CertificateDlg")); 83 d.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CertificateDlg")); 84 85 d.getContentPane().add(CertificatePanel,BorderLayout.CENTER); 86 JPanel buttonPanel = new JPanel (); 87 buttonPanel.setLayout(new FlowLayout (FlowLayout.RIGHT)); 88 buttonPanel.setBorder(BorderFactory.createEmptyBorder(17,12,11,11)); 89 buttonPanel.add(yesButton); 90 buttonPanel.add(noButton); 91 d.getContentPane().add(buttonPanel,BorderLayout.SOUTH); 92 d.setSize(new Dimension (600,600)); 93 d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 94 d.setModal(true); 95 d.setResizable(true); 96 d.setLocationRelativeTo(null); 98 d.setVisible(true); 99 100 if ("yes".equals(command)) { return true; 102 } else { 103 return false; 104 } 105 } 106 107 108 } 109 | Popular Tags |