gpt4 book ai didi

java - JOptionPane 返回字符串

转载 作者:行者123 更新时间:2023-12-01 05:32:28 26 4
gpt4 key购买 nike

我的程序中有一个删除方法,但无法运行。

基本上我有一个数组,用于将数组写入文本文件。然后可以再次读取该文本文件。

要取消预订 JOptionPane出现要求用户输入 RoomID .

一旦该用户完成此操作,它应该返回 roomID 的字符串。并将所有相关详细信息返回到 JOptionPane (我在文本区域中有一个 return 语句,我的程序找到并返回了正确的信息)。

我的 GUI 类从 listBookings 调用我的所有方法类。

public String deleteBooking(String roomID)
{
int index = 0;
for ( Booking s : bookings )
{
if ( s.getRoomID().equals(roomID))
{
int r = JOptionPane.showOptionDialog,null("Are you sure you would like to delete the following \n"
+ "deleteMessage",
"Delete a booking",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,null,null,null);

if (r == JOptionPane.YES_OPTION) {
bookings.remove(index);
}
if (r == JOptionPane.NO_OPTION){
return "Booking Was Not Canceled";
}
}
index++;
}
return " Cannot find room";

新错误消息 <indentifier>预计

最佳答案

尝试使用静态方法(我不确定这是否是正确的语法):

int r = JOptionPane.showOptionDialog("Are you sure you would like to delete the following \n"
+ "deleteMessage",
"Delete a booking",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);

if (r == JOptionPane.YES_OPTION) {
// do delete action
}

关于java - JOptionPane 返回字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8758651/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com