import com.trolltech.qt.gui.*;
public class LoginBox extends QWidget
{
/* Données dont un accès peut-être utile depuis le reste de la classe */
private QLineEdit loginLineEdit;
private QLineEdit passwordLineEdit;
private QLineEdit serverLineEdit;
private QLineEdit portLineEdit;
private QCheckBox sslCheckBox;
private QLineEdit ressourceLineEdit;
public LoginBox()
{
/** Login's GroupBox' **/
QGroupBox loginGroup = new QGroupBox(tr("Login's informations:"));
/* Login Line Edit with Label */
QLabel loginLabel = new QLabel(tr("Jabber ID:"));
loginLineEdit = new QLineEdit();
loginLineEdit.setFocus();
/* Password LineEdit with Label */
QLabel passwordLabel = new QLabel(tr("Password:"));
passwordLineEdit = new QLineEdit();
passwordLineEdit.setEchoMode(QLineEdit.EchoMode.Password);
/* Login's Layout */
QGridLayout loginLayout = new QGridLayout();
loginLayout.addWidget(loginLabel, 0, 0);
loginLayout.addWidget(loginLineEdit, 0, 1);
loginLayout.addWidget(passwordLabel, 1, 0);
loginLayout.addWidget(passwordLineEdit, 1, 1);
loginGroup.setLayout(loginLayout);
/** Account GroupBox **/
QGroupBox accountGroup = new QGroupBox(tr("Server settings:"));
/* Server Line Edit with Label */
QLabel serverLabel = new QLabel(tr("Server:"));
serverLineEdit = new QLineEdit();
/* Port LineEdit with Label and SSL selection */
QLabel portLabel = new QLabel(tr("Port:"));
portLineEdit = new QLineEdit("5222");
sslCheckBox = new QCheckBox(tr("Using SSL"));
/* Ressource Line Edit with Label */
QLabel ressourceLabel = new QLabel(tr("Ressource:"));
ressourceLineEdit = new QLineEdit("jTalk");
/* Login's Layout */
QGridLayout accountLayout = new QGridLayout();
accountLayout.addWidget(serverLabel, 0, 0);
accountLayout.addWidget(serverLineEdit, 0, 1, 1, 2);
accountLayout.addWidget(portLabel, 1, 0);
accountLayout.addWidget(portLineEdit, 1, 1);
accountLayout.addWidget(sslCheckBox, 1, 2);
accountLayout.addWidget(ressourceLabel, 2, 0);
accountLayout.addWidget(ressourceLineEdit, 2, 1, 1, 2);
accountGroup.setLayout(accountLayout);
/* Dialog Button Box */
QDialogButtonBox boutons = new QDialogButtonBox();
boutons.addButton(QDialogButtonBox.StandardButton.Ok);
boutons.addButton(QDialogButtonBox.StandardButton.Cancel);
// Dialog Layout
QGridLayout layout = new QGridLayout();
layout.addWidget(loginGroup, 0, 0);
layout.addWidget(accountGroup, 1, 0);
layout.addWidget(boutons, 2, 0);
setLayout(layout);
setWindowTitle(tr("Jabber Account Configuration"));
setLayout(layout);
}
public static void main
(String args
[]) {
QApplication.initialize(args);
LoginBox widget = new LoginBox();
widget.show();
QApplication.exec();
}
}