Can a JButton be unclickable but not disabled?

The reason I ask this I want the button to be basically disabled but not to lose it's color properties. I have a simple tic tac toe game but I want the X's and O's to be colored, if I set the buttons to disabled they lose their color.
Thanks,
Mike

I'm bored, so here
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Test extends JFrame implements ActionListener {
     JPanel pnl = new JPanel(new GridLayout(3,3));
     JButton [] btn = new JButton[9];
     int player = 0;
     Test () {
          setBounds(200,200,300,300);
          for(int i = 0; i< btn.length; i++)
               btn[i] = new JButton(i+"");
               btn.addActionListener(this);
               pnl.add(btn[i]);
          getContentPane().add(pnl);
          setVisible(true);
     public static void main(String[] args) throws Exception {
          Test t = new Test();
     public void actionPerformed(ActionEvent e) {
          // TODO Auto-generated method stub
          JButton b = (JButton)e.getSource();
          if(b.isSelected())
               return;
          else
               b.setSelected(true);
               b.setBackground(getColor(player));
               player = player == 0 ? 1 : 0;
     private Color getColor(int player)
          if(player == 1)
               return Color.BLUE;
          else
               return Color.RED;
~Tim

Similar Messages

Maybe you are looking for

  • Using iPad air, iPod, iCLoud and WinPro 7 - I am not finding all my tunes and movies among all these devices.

    When I orignally installed iTunes current update, and tried to move about the devices iTunes would crash. I uninstalled it, then reinstalled it. It seems to be stable, however as  before I am not finding all of my TUnes and Movies on all my devices.

  • CVS for solaris 9

    Hi i want cvs for solaris 9.I want to integrate it with JDev. I could not find it anywhere.I can only find it for solaris 8 & 10 Please forward me the link from where i can download it. Thanks

  • Invalid coulmn index

    Im getting invalid coulmn index...any suggestions?...thanx in advance public static int[] getListSummary(UserDataVO userData) throws Exception { Connection connection     = null; PreparedStatement pstmt     = null; ResultSet resultSet          = null

  • Building An Application (GUI)

    I need to create an application that make use of Swing to do up the GUI. Can anyone recommend a software that helps to do to it? Preferably it would be easy to use, drag 'n drop, freeware? I don't have much time to learn to use a new IDE. Also, in th

  • LB in front of IWA IIS servers

    Hi, We have configured IWA authentication scheme with OAM 10g. For this, we are using 2 instances of IIS 7 server. Both of these IIS servers are on 2 different physical machines and have been configured for IWA. Now to achieve HA, we have deployed a