
-----------------------------------
romantic_programmer
Thu Jan 18, 2007 8:36 pm

Jbutton Help
-----------------------------------
Ok, here is my problem.  When i load up my buttons They are automatically enabled. i was wondering if their is a way to have them appear disabled when the buttons load? here is my code maybe some one can help me figure it out.


protected JButton ab, hb, fb, ib;

    public JJRealm_Adventures ()
    {
        ImageIcon leftButtonIcon = createImageIcon ("left.gif");

        ab = new JButton ("Attack", leftButtonIcon);
        ab.setMnemonic (KeyEvent.VK_A);
        ab.setActionCommand ("attack");

        hb = new JButton ("Heal", leftButtonIcon);
        hb.setMnemonic (KeyEvent.VK_H);
        hb.setActionCommand ("heal");

        fb = new JButton ("Flee", leftButtonIcon);
        //Use the default text position of CENTER, TRAILING (RIGHT).
        fb.setMnemonic (KeyEvent.VK_F);
        fb.setActionCommand ("flee");

        ib = new JButton ("Item", leftButtonIcon);
        //Use the default text position of CENTER, TRAILING (RIGHT).
        ib.setMnemonic (KeyEvent.VK_I);
        ib.setActionCommand ("item");

        //Listen for actions on buttons 1 and 3.
        ab.addActionListener (this);
        hb.addActionListener (this);
        fb.addActionListener (this);
        ib.addActionListener (this);

        ab.setToolTipText ("Click this button to attack");
        hb.setToolTipText ("Click this button to defend");
        fb.setToolTipText ("Click this button to flee");
        ib.setToolTipText ("Click this button to access an item");

        //Add Components to this container, using the default FlowLayout.
        add (ab);
        add (hb);
        add (fb);
        add (ib);
    }


    public void actionPerformed (ActionEvent e)
    {

        if ("attack".equals (e.getActionCommand ()))
        {
            monsterHP = (monsterHP - (playerATK - monsterAP));
            playerHP = (playerHP - (monsterATK - playerAP));
            drawPlayerGrid ();
            playerStats ();
            c.clear ();


        }
        else if ("heal".equals (e.getActionCommand ()))
        {
            playerHP = playerHP + 15;
            c.clear ();

        }
        else if ("flee".equals (e.getActionCommand ()))
        {
            c.clear ();

            c.setFont (Battle);
            c.drawString ("you have fled", 50, 50);
            c.getChar ();
            condition = 5;
        }
        else if ("item".equals (e.getActionCommand ()))
        {

        }

        if (monsterHP 