• Post Reply Bookmark Topic Watch Topic
  • New Topic

To change the colore of the clicked Jbutton  RSS feed

 
Yugendra Reddy Guvvala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been devoloping a TIC TAC TOE applicaton i know how to make the button disabled by marking the users or computers mark but i dont know how to change the colore of the button when it is clicked


buttons.setText("O");
buttons.setEnabled(false);

this is how i have been doing that
i tried


buttons.setBackground("color.red")

but it says setbackground function not found in javax.swings

please let me know do i have to import any other packages other than

javax.swing.*
java.awt.*
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

buttons.setBackground("color.red")
[/QB]


Use buttons.setBackground(Color.RED); instead of "color.red"
 
Yugendra Reddy Guvvala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been programming in anetbeans IDE when ever i write the error comes saying

cannot find symbol
symbol:method setBackgroud(java.awt.color)
location javax.swing.jbutton[]

teh method setBackground()is underlined
shuld i include any other packages ie import any other than

javax.swing.*
java.awt.*
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...
location javax.swing.jbutton[]
[/QB]


Is jbutton[] an array?
 
Yugendra Reddy Guvvala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is
 
Yugendra Reddy Guvvala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my prob lem is solved but how to set teh colore with rgb values
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
myButton.setBackground(new Color(0x12, 0x34, 0x56)); ?
[ February 27, 2008: Message edited by: Campbell Ritchie ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!