java - 多个意图取决于选择的单选按钮
问题描述
可以根据选择的单选按钮转到特定课程吗?是否可以在 onClick 中为新意图创建 if-else 语句?
例如,
圆形、方形、三角形单选组按钮。圈子已被选中。
在 "onClick" 中有一个 if-else 语句有 "circle.class", "square.class", "triangle.class" 意图会转到 "circle.class"
解决方案
是的,很有可能!你要做的就是调用所需类的mainn方法(或任何其他方法)如果方法是静态的,直接通过类引用调用它,它是非静态的,然后使用该类的对象(注意NullPointerException 虽然)
1)确保您的圆形或三角形(或其他)类已创建
您可以:在 jRadioButton1 的 ActionPerformed() 事件下
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
if(jRadioButton.isSelected() == true)
{
circle.main() //
}
}
推荐阅读
- intellij-idea - 为什么 pycharm 尝试自动执行 ssh-add?
- jsf - ChartUtilities.getImageMap() 未在 JSF 中生成工具提示
- php - 自然语言实体提取
- python - re.split 拆分表达式并保留分隔符/涉及括号
- javascript - 延迟 css 动画样式组件
- prometheus - 在 alertmanager 中添加自定义 webhook 配置
- triggers - 避免在 Salesforce 中插入记录的解决方案
- javascript - 如何解决 svg 元素未呈现为图像的问题 (dom2img)
- c# - WPF - 如何获取 DataGrid 中每一行的高度?
- html - 块问题内垂直对齐的 inline-flex