Ejemplo n.º 1
0
 public void eventDispatched(java.awt.AWTEvent awte)
 {
     // support modifications to the logon dialog
     if (awte.getID() == [email protected]_OPENED)
     {
         var frame = awte.getSource() as javax.swing.JFrame;
         if (frame != null && LogonDialog.match(frame))
         {
             LogonDialog.wrap(this.getForm(), frame);
         }
     }
 }
Ejemplo n.º 2
0
        public static void wrap(Form owner, javax.swing.JFrame frame)
        {
            // fetch the required gui elements
            var panelOuter    = (javax.swing.JPanel)frame.getContentPane().getComponent(0);
            var panelInner    = (javax.swing.JPanel)panelOuter.getComponent(0);
            var userNameInput = (javax.swing.JTextField)panelInner.getComponent(2);
            var passwordInput = (javax.swing.JPasswordField)panelInner.getComponent(4);
            var okButton      = (javax.swing.JButton)panelInner.getComponent(7);

            // update the dialog title and input boxes
            frame.setTitle("Consens-Anmeldung");
            userNameInput.setText(Credentials.UserName);
            passwordInput.setText(Credentials.Password);

            // create a checkbox for specifying whether to persist the credentials
            var saveCredentialsInput = new javax.swing.JCheckBox("Kennwort speichern", Credentials.Save);
            var c = new java.awt.GridBagConstraints();

            c.fill  = java.awt.GridBagConstraints.HORIZONTAL;
            c.gridx = 4;
            c.gridy = 4;
            panelInner.add(saveCredentialsInput, c);
            frame.validate();

            // hook the required events
            var dialog = new LogonDialog(userNameInput, passwordInput, saveCredentialsInput);

            passwordInput.addPropertyChangeListener("enabled", dialog);
            okButton.addActionListener(dialog);

            // turn the WinForm into a dialog
            var form = frame.getForm();

            form.BeginInvoke(new MethodInvoker(() =>
            {
                form.Owner           = owner;
                form.MinimizeBox     = false;
                form.MaximizeBox     = false;
                form.ShowInTaskbar   = false;
                form.FormBorderStyle = FormBorderStyle.FixedDialog;
                form.Focus();
            }));
        }