29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

y = (buttonHeight - (int) bounds.getHeight()) / 2 + (int) bounds.getHeight()<br />

- metrics.getDescent();<br />

setTextCoords = true;<br />

}<br />

g.drawString(buttonText, x, y);<br />

}<br />

private class buttonListener implements MouseListener<br />

{<br />

public void mousePressed(MouseEvent e)<br />

{<br />

buttonLabel.setIcon(buttonIcons[1]);<br />

pressed = true;<br />

}<br />

public void mouseReleased(MouseEvent e)<br />

{<br />

pressed = false;<br />

if(e.getX() < buttonWidth && e.getX() > 0 && e.getY() < buttonHeight &&<br />

e.getY() > 0)<br />

{<br />

buttonLabel.setIcon(buttonIcons[2]);<br />

fireAction(new ActionEvent(this, 1, buttonText));<br />

}<br />

else<br />

buttonLabel.setIcon(buttonIcons[0]);<br />

}<br />

}<br />

public void mouseClicked(MouseEvent e)<br />

{<br />

}<br />

public void mouseEntered(MouseEvent e)<br />

{<br />

if(pressed)<br />

buttonLabel.setIcon(buttonIcons[1]);<br />

else<br />

buttonLabel.setIcon(buttonIcons[2]);<br />

}<br />

public void mouseExited(MouseEvent e)<br />

{<br />

buttonLabel.setIcon(buttonIcons[0]);<br />

}<br />

EventListenerList actionListeners = new EventListenerList();<br />

public void addActionListener(ActionListener listener)<br />

{<br />

actionListeners.add(ActionListener.class, listener);<br />

}<br />

public void removeActionListener(ActionListener listener)<br />

{<br />

actionListeners.remove(ActionListener.class, listener);<br />

}<br />

protected void fireAction(ActionEvent actionEvent)<br />

{<br />

Object[] listeners = actionListeners.getListenerList();<br />

}<br />

// loop through each listener and pass on the event<br />

for(int i = 0; i < listeners.length; i++)<br />

{<br />

if(listeners[i] instance<strong>of</strong> ActionListener)<br />

((ActionListener) listeners[i]).actionPerformed(actionEvent);<br />

}<br />

241

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!