gpt4 book ai didi

java - JComboBox 是否有 postActionEvent?

转载 作者:行者123 更新时间:2023-12-01 12:23:51 25 4
gpt4 key购买 nike

我成功地在具有 ActionListener 的 JTextField 上使用 postActionEvent() 来模拟用户操作(按 Enter 键)。我想为具有 ActionListener 的 JComboBox 创建相同类型的模拟,但我没有找到 JComboBox 的 postActionEvent()。这是如何实现的(模拟用户按 Enter 键)?

最佳答案

How could this (simulating User pressing Enter key) be accomplished?

组合框有一个“enterPressed”操作。因此,您应该能够从组合框的 ActionMap 访问 Action,然后手动调用组合框的 actionPerformed(...) 方法行动。

查看Key Bindings让程序列出所有 Swing 组件的所有绑定(bind)。

关于java - JComboBox 是否有 postActionEvent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26493650/

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