#Updating Label from object created in Pagination method

1 messages · Page 1 of 1 (latest)

gilded pivot
#

Sorry if title is worded the worst. I am learning JavaFX, and am making a simple scheduling app for myself. Right now my goal is a a display schedule page, which will have a button next to each task, allowing me to edit. The shedule is displayed as a Pagination and a ListView, containing a Label and two buttons for each task on the list. I've done test outputs, and I know item contains the task I need, however no matter where I try and do editLabel.setText(item.display()); it won't update on the edit page when opened. I have tried it in every method involved, and only one where the Label will be set, is in intialize(), however (to my knowledge) i cant change intialize()'s param's or find a way to send item in, to update with that. I have tried having a class variable for the task, and assigning task = item, before the switchEditScene call, and hopefully intialize. I feel this is making no sense but I can't get it to work. Attached should be all relevant code.

chilly ingotBOT
#

<@&987246487241105418> please have a look, thanks.

chilly ingotBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

edule that shows one week at a time, with the ability to navigate to the previous or next week. I have created a Pagination object with a Label for each day of the week. My issue is that I am not sure how to update the labels with the correct dates when navigating to a different week. Here is my code so far:

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Pagination;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ScheduleApp extends Application {

    private static final int DAYS_PER_WEEK = 7;

    @Override
    public void start(Stage primaryStage) {
        Pagination pagination = new Pagination();
        pagination.setPageCount(52); // 52 weeks in a year
        pagination.setCurrentPageIndex(0); // start at first week

        pagination.setPageFactory(pageIndex -> {
            VBox page = new VBox();
            page.setPadding(new Insets(10));

            for (int i = 0; i < DAYS_PER_WEEK; i++) {
                Label label = new Label(); // label for each day of the week
                page.getChildren().add(label);
            }

            return page;
        });

        Scene scene = new Scene(pagination, 400, 300);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

I would like to update the labels with the correct dates when navigating to a different week. For example, if I navigate to the second week, I would like the labels to display the dates for that week (e.g., "January 8", "January 9", etc.). How can I achieve this?

gilded pivot
#

dawg what

#

this is like nothing i needed