Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A password dialogue input function

Featured Replies

Has a bit of help from Sam Barnum on StackOverflow with this but have a function which either gives you three chances to enter the correct password, or returns the password you enter into the box.

Just a bit of practice for me with SwingBuilder but might be a useful starting point for others.

Some of this has been enabled by the latest Groovy 1.8.4 version in the current Scriptmaster


// PasswordSwing ( title ; message ; type ; password ; returnPass )

// 12_02_21 JR

// v1.0

// type -1 plain, 0 error, 1 information, 2 warning, 3 question

// if returnPass then displays a dialogbox with a password field and returns the passsword on OK

// and uses title and password parameters and returns entered text

// else gives three attempts to enter a password which matches password parameter

// returns true if match if not or dialog cancelled returns false





import javax.swing.JComponent

import groovy.swing.SwingBuilder



type = type.toInteger()

i = 0

left = ''

swing = new SwingBuilder()



if(returnPass){

swing.edt{

  passwordField = passwordField()

  JComponent[] components = [label(message), passwordField]

  result = optionPane().showConfirmDialog(null, components, title, 2, type)

}

return passwordField.getPassword().toString()

} else {

swing.edt{

  passwordField = passwordField()

  while(i < 3){

   JComponent[] components = [label('Password'+left), passwordField]

   result = optionPane().showConfirmDialog(null, components, title, 2, -1)

   if (passwordField.getPassword().toString() == password || result == -1 || result == 2){

    i=3

   } else if (passwordField.getPassword().toString() != password && i==2) {

    result = optionPane().showMessageDialog(null, '<html><h1><font color="red">WRONG PASSWORD</font></h1><h3>Script halted</html>', 'ERROR', 2)

    i=3

   } else {

    result = -1

    i++

    message = i == 2 ? ' try':' tries'

    left = ' - ' + (3-i) + "${message}" + ' left'

    passwordField = passwordField()

   } //end if

  } //end while

} //end swing

return result == 0 ? true:false

}



Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.