• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane with lable and textfield  RSS feed

 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In JOptionPane, I want to show password label and its corresponding password textfiled in one line and then confirm password label and corresponding textfield in another line. Can anybody give me sample code for this ??

I am able to put the controllers in the JOptionPane one below the other. But not one after the other.


private ButtonGroup buttonGroup = new ButtonGroup();
private JRadioButton radioButton1 = new JRadioButton("Use default password");
private JRadioButton radioButton2 = new JRadioButton("I have changed the password");
private JLabel passwordLbl = new JLabel("Password:");
private JTextField passwordTF = new JTextField();

private Object[] pwdArray = {passwordLbl, passwordTF};

private String difficultyString = "<html>Log in to the database failed.<br>Please select any of the following options below.</br></html>";
private Object[] radioButtonArray = {difficultyString, radioButton1, radioButton2, pwdArray};

JOptionPane.showConfirmDialog(this,
radioButtonArray, "Level selection",
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE);

Please suggest me some way to achieve this.

Regards,
Satya
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by satya sahu:

JOptionPane.showConfirmDialog(this,
radioButtonArray, "Level selection",
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE);

Please suggest me some way to achieve this.


1) Create a JPanel instance.
2) Add all your components (radio buttons, labels, password fields etc) to it
3) Pass the panel to the JOptionPane instead of the radioButtonArray.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!