每次单击一个按钮时用新文本更新标签

0 java javafx

我正在尝试为我的大学项目制作一部交互式视觉小说,但我不知道如何仅用一个按钮将标签的文本更新为下一行对话。

\n
public void NicoleDialogue() {\n    String[] NDialogue = {"My name is Tala Nicole Dimaapi Valdez / Joshua Manuel Garcia Reyes, I know a long ass name but I\xe2\x80\x99m filipino what can I say?",\n    "I\xe2\x80\x99m a student of DLSU, one of the most prestigious universities in the country and today I will join GreenGiant FM, an organization for people who want to become radio hosts or who are just interested in radio hosting in general.",\n    "It is my first time joining an organization in this school so I\xe2\x80\x99m a bit nervous since I don\xe2\x80\x99t really know anybody from the org but there is no time for getting nervous right now since I\xe2\x80\x99m about to open the door"};\n\n    for(int i = 0; i < NDialogue.length; i++) {\n        NLine1.setText(NDialogue[i]);\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

到目前为止,我已经尝试制作一系列我想要显示的对话,以及一个每次点击都会循环播放对话的循环,但它不起作用,此时我几乎迷失了方向。

\n

jew*_*sea 6

\n

每次点击都会循环播放对话的循环

\n
\n

你必须改变你的想法。您不\xe2\x80\x99t 为此使用循环。

\n

GUI 是事件驱动的。用户和系统生成您需要处理的事件:

\n
    \n
  1. 存储索引。
  2. \n
  3. 提供事件处理程序。\n
      \n
    • 查看按钮setOnActionjavadoc。
    • \n
    \n
  4. \n
  5. 在事件处理程序中,检查文本是否保留后:\n
      \n
    • 增加索引,
    • \n
    • 将标签文本设置为新索引的行。
    • \n
    \n
  6. \n
\n