Hi everybody,

I was wondering if it is possible (and if it is, how to do it) to put a JPasswordField into a JOptionPane.

Thanks in advanced,

I think JDialog is the best to use when puting custom components like that in.

can you please explain how to use JDialog???

Thanx in advanced,

Here is an example, but remember this is just an inner class.

class processCylinderDialog extends JDialog implements ActionListener
	 JLabel lblRadius;
	 JLabel lblHeight;
	 JTextField txtRadius;
	 JTextField txtHeight;
	 JButton btnDone;
	 JDialog dlg;
	 public processCylinderDialog()
		 JPanel panelOne = new JPanel();
		 lblRadius = new JLabel("Radius");
		 txtRadius = new JTextField(10);
		 JPanel panelTwo = new JPanel();
		 lblHeight = new JLabel("Height");
		 txtHeight = new JTextField(10);
		JPanel panelThree = new JPanel();
		btnDone = new JButton("Calculate");
		 dlg = new JDialog();
		 dlg.setTitle("Cylinder Volume");
		 dlg.getContentPane().setLayout(new FlowLayout());
	 public void actionPerformed(ActionEvent ae)
	 public void getInfo()
		 if (txtRadius.getText() != null && txtHeight.getText() != null)
		 double cylRadius = Double.parseDouble(txtRadius.getText());
		 double cylHeight = Double.parseDouble(txtHeight.getText());
		 double cylVolume = Math.PI * cylRadius * cylRadius * cylHeight;
		 txtResult.setText(dec.format(cylVolume) + "");
	   catch(NumberFormatException nfe)

You can see that it is just like creating a class that extends JFarme with a few modifications.

When you want to display this dialog, you call it like this:

new className();

Thank you very much, server_crash!!!

Thank you very much, server_crash!!!

Your very welcome, and if you need any further help just let me know, or Pm me.

Actually, that didn't work!!

Is there any other way (Preferably in JOptionPane)?

regard previous message - i forgot to put in:

new className();

Why don't you post your code, preferably all of it, but most importantly the JDialog inner class and where you call it.

thanx - but the code's working now. I have one more question:

Is there a way to figure out which character is most common in a string?

Here's a common example:

static int countChars( String str, char searchChar ) {
                  // Count the number of times searchChar occurs in
                  // str and return the result.
                int i;     // A position in the string, str.
                char ch;   // A character in the string.
                int count; // Number of times searchChar has been found in str.
                count = 0;
                for ( i = 0;  i < str.length();  i++ ) {
                    ch = str.charAt(i);  // Get the i-th character in str.
                    if ( ch == searchChar )
                return count;