I have a simple JOptionPane with some components and I want to arrange them.
For example I want to put the label next to the text/password field, sets their width etc..
This is like how I did it, of course the result wasn't what I wanted:
public class CreateApplicationUserScreen {
CreateApplicationUserScreen(){
JLabel l_name=new JLabel("Username");
JLabel l_pass=new JLabel("Password");
JTextField tf_name=new JTextField(10);
JPasswordField pf_pass=new JPasswordField(10);
JButton b_privs = new JButton("Privs");
JButton b_databases = new JButton("Databases");
int res = JOptionPane.showOptionDialog(window,
new Object[] { l_name, tf_name,
l_pass, pf_pass,
b_privs, b_databases },
"Create application user",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,null,
new String[]{"Create", "Cancel"},
"default");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…