gpt4 book ai didi

java - 动态更改 Tab UIID 在 codenameone 中无法正常工作

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

我正在其中一种表单中使用选项卡。

如果保存表单时发生任何错误,则选项卡颜色应更改。

我使用的代码如下:

for(Integer tabIndex: errorTabIndex){
if(index==0){
tabs.setSelectedIndex(tabIndex);
}
Button c = (Button) tabs.getTabsContainer().getComponentAt(tabIndex);
c.setUIID("Tab_button_error");
c.repaint();
index++;
}

此代码设置了新的 UIID,但是当我单击选项卡时,它会重置以前的 UIID 样式,而不是坚持新的 UIID 样式。

最佳答案

选项卡不是按钮,而是单选按钮。

如果选择了要应用的选项卡,您的 uiid Tab_button_error 应该选择您想要显示的样式,否则设置未选择的样式。

应该在选项卡容器上调用 repaint()revalidate() 方法,而不是在 RadioButtons 上调用。

使用组件检查器检查选项卡 RadioButton 的状态以及它们携带的 UIID。

for(Integer tabIndex: errorTabIndex) {
if(index==0) {
tabs.setSelectedIndex(tabIndex);
}
RadioButton radTab = (RadioButton) tabs.getTabsContainer().getComponentAt(tabIndex);
radTab.setUIID("Tab_button_error");
tabs.getTabsContainer().repaint();
index++;
}

关于java - 动态更改 Tab UIID 在 codenameone 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35034591/

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