Added password and date feature need to modify scrollpane with selector

This commit is contained in:
shaggy3007 2023-10-17 15:48:05 +02:00
parent b0344bbe24
commit 2fdec5aaa9
2 changed files with 35 additions and 8 deletions

View File

@ -5,8 +5,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
@ -18,7 +22,17 @@ public abstract class AbstractAppPane implements AppPane {
protected Scene scena = new Scene(pannello);
protected int heigth, width, insets;
protected List<String> Names = new ArrayList<>();
@Override
protected ObservableList<String> Countries = FXCollections.observableArrayList() ;
protected ListView<String> CountriesList = new ListView<>(Countries);
protected void fillCountries(Iterable<String> CountriesNames) {
for (String Name: CountriesNames) {
Countries.add(Name);
}
CountriesList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
}
abstract public void gridSetup();

View File

@ -7,6 +7,9 @@ import java.util.HashMap;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.PasswordField;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
@ -22,9 +25,15 @@ public class RegPane extends AbstractAppPane {
pannello.setHgap(5);
pannello.setAlignment(Pos.CENTER);
int x = 0;
for (String s : Names) {
pannello.add(Texts.get(s),0,x);
pannello.add(Fields.get(Texts.get(s)), 1, x++);
for (String name : Names) {
pannello.add(Texts.get(name),0,x);
pannello.add(Fields.get(Texts.get(name)), 1, x++);
if (name.equals("Luogo")) {
((ScrollPane)Fields.get(Texts.get(name))).setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
((ScrollPane)Fields.get(Texts.get(name))).setFitToWidth(true);
}
}
Button RegButton = new Button("Register");
RegButton.setOnAction( e -> {
@ -53,6 +62,10 @@ public class RegPane extends AbstractAppPane {
for (String s: S) {
Names.add(s);
}
ArrayList<String> TEST = new ArrayList<>();
TEST.add("China");
TEST.add("Korea");
fillCountries(TEST);
textFill();
gridSetup();
}
@ -67,17 +80,17 @@ public class RegPane extends AbstractAppPane {
for (String Name : Names) {
if ( Name.equals("Luogo") ) {
Texts.put( Name, new Text(Name+" di nascità") );
Fields.put( Texts.get(Name), new TextField() );
Fields.put( Texts.get(Name), new ScrollPane( CountriesList ) );
} else if ( Name.equals("Data") ) {
Texts.put(Name, new Text(Name+" di nascità") );
Fields.put( Texts.get(Name), new TextField() );
Fields.put( Texts.get(Name), new DatePicker() );
} else if ( Name.equals("Password") ) {
Texts.put( Name, new Text(Name) );
Fields.put( Texts.get(Name), new TextField() );
Fields.put( Texts.get(Name), new PasswordField() );
} else if ( Name.equals("RPassword") ) {
Texts.put( Name, new Text("Repeat Password") );
Fields.put( Texts.get(Name), new TextField() );
Fields.put( Texts.get(Name), new PasswordField() );
} else {
Texts.put( Name, new Text(Name) );