我可以改变颜色的一种方法是使用setForground().但是,当有多行代码时,它会使所有内容变为绿色或黑色.有没有其他方法或任何方法来解决这个问题?谢谢!
int key = evt.getKeyCode();
if (key == KeyEvent.VK_ENTER)
{
String tb1EnterdValue = tb1.getText().toString();
if((tb1EnterdValue.equals("yes")) )
{
TextArea1.setForeground(Color.green);
else
{
TextArea1.setForeground(Color.lightGray);
}
this.TextArea1.append(">"+tb1EnterdValue+newline);
this.tb1.setText("");
Run Code Online (Sandbox Code Playgroud) 我的程序以JFrame中带有文本字段的图片开头.我想在用户类型启动时关闭图片JFrame并打开另一个JFrame与主程序.我试过了
processEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
在图像框架上,但它关闭所有窗口.