package greenfoot.guifx.export;
import bluej.Config;
import bluej.utility.javafx.FXCustomizedDialog;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Window;
import threadchecker.OnThread;
import threadchecker.Tag;
| Display a "proxy authentication required" dialog, prompting for username and password.
|*
* @author Davin McCall
* @author Amjad Altadmri
*/
@OnThread(Tag.FXPlatform)
public class ProxyAuthDialog extends FXCustomizedDialog<ProxyAuthDialog.ProxyAuthInfo>{
|
|private final TextField usernameField = new TextField();
|
|private final PasswordField passwordField = new PasswordField();
|
|/**
| Construct a new proxy authentication dialog.
|
| @param parent The owner {}link Window} for this dialog.
| Should not be null, as this is not a top Application window.
|
public ProxyAuthDialog(Window parent)
{
super(parent, Config.getString("export.publish.proxyAuth"), null);
setModal(true);
buildUI();
getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
getDialogPane().lookupButton(ButtonType.OK).disableProperty()
.bind(usernameField.textProperty().isEmpty().or(passwordField.textProperty().isEmpty()));
setResultConverter(bt -> bt == ButtonType.OK
? new ProxyAuthInfo(usernameField.getText(), passwordField.getText())
: null);
}
| Build the user interface
|
private void buildUI()
{
GridPane authPanel = new GridPane();
usernameField.setPrefColumnCount(20);
passwordField.setPrefColumnCount(20);
authPanel.addRow(0, new Label(Config.getString("export.publish.username")), usernameField);
authPanel.addRow(1, new Label(Config.getString("export.publish.password")), passwordField);
setContentPane(new VBox(new Label(Config.getString("export.publish.needProxyAuth")), authPanel));
}
| Proxy authentication credentials.
|
public class ProxyAuthInfo
{
private String username;
private String password;
private ProxyAuthInfo(String username, String password)
{
this.username = username;
this.password = password;
}
public String getUsername()
{
return username;
}
public String getPassword()
{
return password;
}
}
}
. ProxyAuthDialog
. buildUI
top,
use,
map,
class ProxyAuthInfo
. ProxyAuthInfo
. getUsername
. getPassword
79 neLoCode
+ 9 LoComm