Android: what to choose for requestcode values?

Documenting the findings for future reference: The following are code from android.support.v4.app.FragmentActivity /** * Modifies the standard behavior to allow results to be delivered to fragments. * This imposes a restriction that requestCode be <= 0xffff. */ @Override public void startActivityForResult(Intent intent, int requestCode) { if (requestCode != -1 && (requestCode&0xffff0000) != 0) { throw … Read more

JOptionPane to get password

Yes, it is possible using JOptionPane.showOptionDialog(). Something like this: JPanel panel = new JPanel(); JLabel label = new JLabel(“Enter a password:”); JPasswordField pass = new JPasswordField(10); panel.add(label); panel.add(pass); String[] options = new String[]{“OK”, “Cancel”}; int option = JOptionPane.showOptionDialog(null, panel, “The title”, JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); if(option == 0) // pressing OK button { char[] … Read more

How to create a notification in swing

You might need a translucent frame without decorations. Quick demo OSX ] You can take advantage JLabel displays simple HTML import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*; import java.util.Date; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; /** * Simple demo on how a translucent window * looks like when is used to display the system clock. * … Read more