如何更改Java中特定表格单元格的背景颜色??? [英] how to change the background color of specific table cell in java???

查看:163
本文介绍了如何更改Java中特定表格单元格的背景颜色???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我想在Java JTable中更改特定表单元格的背景颜色.........

给定的原始编号和列编号???

我试过了,但我只能使用鼠标侦听器通过鼠标更改所选单元格的背景.

像这样

<br />
table.setSelectionBackground(Color.red);<br />



但我想根据其原始和列号更改表格单元格

如果有人知道我该怎么做,请尽快帮助我?


在此先感谢.

Basem Moghram,

解决方案

由于我给了你这个虚假的答案,我以为我会为你研究这个问题,即使我不太了解Java好吧.

似乎没有简单的方法可以做到这一点.您显然必须创建一个自定义TableCellRenderer. 本文详细介绍了如何执行此操作. blockquote>

感谢aspdotnetdev对您的回答


但我已经有了原始编号和列编号

我只想更改此单元格的背景.

我该怎么办?
谢谢.

Basem,


非常感谢aspdotnetdev,:)

我以前看过该链接,但由于此代码更改了整个表格的单元格的背景,问题仍然存在:(


谢谢


hello everybody :)

I want to change the background color of specific table cell in java JTable.........

given raw number and column number???

i tried that but i can only change the background of selected cell by mouse using mouse listener.

like this

<br />
table.setSelectionBackground(Color.red);<br />



but i want to change the table cell according to its raw and column numbers

if anyone know how can i do that please help me as soon as possible ?


thanks in advance.

Basem Moghram,

解决方案

Since I gave you that bogus answer, I thought I''d look into this for you, even though I don''t know Java very well.

Looks like there is no easy way to do this. You apparently have to create a custom TableCellRenderer. This article describes how to do this in detail.


Thanks aspdotnetdev for ur answer


but i already have the raw and column numbers

and i want to change the background of this cell only.

how can i do that ????

Thanks .

Basem,


Thanks aspdotnetdev very much , :)

i have seen that link before and the problem still found since this code change the background of the whole table''s cell :(


Thanks,


这篇关于如何更改Java中特定表格单元格的背景颜色???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆