aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to applty setMneomonic in Confirm Dialog of JOption Pane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to applty setMneomonic in Confirm Dialog of JOption Pane " Watch "How to applty setMneomonic in Confirm Dialog of JOption Pane " New topic
Author

How to applty setMneomonic in Confirm Dialog of JOption Pane

aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
hi I am using

i know how to set the hot keys( setMnemonic(char)) in the JButton but i dont know how to use it in JOptionPane
Also i want to take password input from JOptionPane.showInputDailog
how i can call setEchoCahr('*');
for input dialog
thanks
Regards
Md Aminur Rashid
Pune

Regards<br />Aminur
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hi Aminur,
try:
JPanel panel = new JPanel();
JLabel label = new JLabel("type your password:");
JPasswordField passField = new JPasswordField();
panel.setLayout(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.add(passField, BorderLayout.SOUTH);
JOptionPane.showConfirmDialog(null, panel, "Password request", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
char[] password = passField.getPassword();
hava fun,
chantal
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Thanks tell me also how to call setMnemonic(char c);
for the Yes_No option of JOptionPane.showConfirmDialog
Originally posted by Chantal Ackermann:
hi Aminur,
try:
JPanel panel = new JPanel();
JLabel label = new JLabel("type your password:");
JPasswordField passField = new JPasswordField();
panel.setLayout(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.add(passField, BorderLayout.SOUTH);
JOptionPane.showConfirmDialog(null, panel, "Password request", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
char[] password = passField.getPassword();
hava fun,
chantal

Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hi Aminur,
have you tried if this mnemonic isn't already set by default? I mean, write a small test application and see if the button is marked as and reacts like a mnemonic.
if not: use
JOptionPane.showOptionDialog()

with the same parameter set as above, but additionaly specifying Object[] options (and what else will be necessary).
API: JOptionPane.showOptionDialog()
Parameter options - an array of objects indicating the possible choices the user can make; if the objects are components, they are rendered properly.
that means you can provide buttons with a mnemonic specification as argument.
chantal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to applty setMneomonic in Confirm Dialog of JOption Pane