Changeing the JButtion color when Mouseevent occurs

Hi.

In my swing application I want to change the color of my JButton. when I move My mouseover the JButton, i want to change the color of JButton permanently when i click the JButton.

Thanks in advance

cheers

Mallik

[248 byte] By [mallik.83a] at [2007-11-27 10:28:08]
# 1

use mousemotion listener and action listener.

then use setBackground(Color);

mouse motion:

button.addMouseMotionListener( new java.awt.event.MouseMotionListener() {

public void mouseDragged(MouseEvent e) {

}

public void mouseMoved(MouseEvent e) {

// code here

}

})

Action listener:

btnAdd.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(ActionEvent e) {

}

});

Message was edited by:

Yannix

Message was edited by:

Yannix

Yannixa at 2007-7-28 17:49:57 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks...

Using button.addMouseMotionListener i am able to change color of the JButton .when i move the mouse over the JButton ...... but i want to change the color of the JButton Permanent when i click the JButton ..

cheers

mallik

mallik.83a at 2007-7-28 17:49:57 > top of Java-index,Desktop,Core GUI APIs...
# 3

do that in action listener

Aniruddha-Herea at 2007-7-28 17:49:57 > top of Java-index,Desktop,Core GUI APIs...