-1
bsave.setOnAction( e -> savecontacts());

private void savecontacts(){

    Name.getText();
    PhoneNumber.getText();
    Address.getText();
    System.out.println("Save");
}

Rectangle rect = new Rectangle(0, 500, Color.WHITE);
ScrollPane sp = new ScrollPane();
sp.setPrefSize(280, 280);
sp.setContent(rect);

In event handling .. I am getting data from textFeilds to save data. Now I have to Show this data in Scrollpane.How I will show?

1 Answers1

1

Consider using a TableView, which allows you to display several columns of data based on item data. (ListView being an alternative for a single "column" without a header.) It automatically adds a ScrollBar, if the number of items cannot be shown in size available to the TableView without scrolling.

In this case all you'd need to do in the event handler would be adding a new item to the TableView, e.g. something like this

private void savecontacts(){
    contactsTable.getItems().add(new Contact(Name.getText(), PhoneNumber.getText(), Address.getText()));
    System.out.println("Save");
}

(Contact would be your item class in this case)

Graham
  • 7,431
  • 18
  • 59
  • 84
fabian
  • 80,457
  • 12
  • 86
  • 114