gpt4 book ai didi

java - 为什么 HTML 标签在我的 java 程序中不起作用?

转载 作者:太空宇宙 更新时间:2023-11-04 12:35:30 25 4
gpt4 key购买 nike

这一行:

array[x][y].setText("<html><font color = black>0</font></html>");

不起作用。没有任何编译或运行时错误,但在运行时,我在 JGrasp 的控制台中看到了这一奇怪的行:

[0x7FFFAAC25520] ANOMALY: meaningless REX prefix used

有人知道我能做什么吗?我正在设置 JButton 的文本,并且使用 html 标记,而不是 setForeground(),因为 setForeground() 不适用于禁用的 setEnabled(false)- 按钮。

如果有帮助的话,这是它的完整部分:

  public void reveal(int x, int y)
{
array[x][y].setEnabled(false);
array[x][y].setBackground(gray);

int p = Integer.parseInt(array[x][y].getText());
switch(p){
case 0: array[x][y].setText("<html><font color = black>0</font></html>");
zero(x, y);
break;
case 1: array[x][y].setText("<html><font color = red>1</font></html>");
break;
case 2: array[x][y].setText("<html><font color = blue>2</font></html>");
break;
case 3: array[x][y].setText("<html><font color = green>3</font></html>");
break;
case 4: array[x][y].setText("<html><font color = purple>4</font></html>");
break;
case 5: array[x][y].setText("<html><font color = pink>5</font></html>");
break;
case 6: array[x][y].setText("<html><font color = brown>6</font></html>");
break;
case 7: array[x][y].setText("<html><font color = yellow>7</font></html>");
break;
case 8: array[x][y].setText("<html><font color = orange>8</font></html>");
break;
case 9:
remove(board);
revalidate();
repaint();
end.setText("Ouch. You hit a bomb!");
add(end, BorderLayout.CENTER);
break;
}

有人知道我能做什么吗?

最佳答案

您提到您的 JButton 已被禁用。您是否考虑使用setDisabledIcon(Icon disabledIcon)?您所需要的只是一个图标(可以只是纯色)。

关于java - 为什么 HTML 标签在我的 java 程序中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37377526/

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