gpt4 book ai didi

java - 同步呈现 JFrame

转载 作者:行者123 更新时间:2023-11-30 05:06:48 25 4
gpt4 key购买 nike

我有这个主 JFrame(称为 DrinkChooser),它显示另一个复杂的确认 JFrame(称为ConfirmWin)。

ConfirmWin 只有两个 JButton,确认和取消。

我想这样做:

(在 DrinkChooser 中,假设 DrinkChoosen 是 Drink[])

public void handleAction(){
int choice = ConfirmWin.showDrinkConfirmation(drinksChoosen);

if(choice == ConfirmWin.CONFIRM)
//Handle confirmation.
else
//handle cancel, do nothing.
}

我想要实现一个尽可能接近“JOptionPane效果”的效果,即原来的DrinkChooser被暂停,ConfirmWin返回用户的选择。

谢谢。

最佳答案

看看路线 How to Make Dialogs .

A Dialog window is an independent subwindow meant to carry temporary notice apart from the main Swing Application Window. Most Dialogs present an error message or warning to a user, but Dialogs can present images, directory trees, or just about anything compatible with the main Swing Application that manages them.

For convenience, several Swing component classes can directly instantiate and display dialogs. To create simple, standard dialogs, you use the JOptionPane class.

这是一个可能相关的问题:

关于java - 同步呈现 JFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4842745/

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