X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix_swing%2Fgui%2FSearchBar.java;h=2dd458790448e346e8b1a722c52e619d744f6255;hp=ee5896e1d9823408632007dee63b6a22b04b4a11;hb=2a03ecc0ae449a05763db2d47935a4c256cd092f;hpb=59253323f07e6a67ef6c8e197fd1065a81c7069a diff --git a/src/be/nikiroo/fanfix_swing/gui/SearchBar.java b/src/be/nikiroo/fanfix_swing/gui/SearchBar.java index ee5896e..2dd4587 100644 --- a/src/be/nikiroo/fanfix_swing/gui/SearchBar.java +++ b/src/be/nikiroo/fanfix_swing/gui/SearchBar.java @@ -8,10 +8,10 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JButton; -import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; +import be.nikiroo.fanfix_swing.gui.utils.ListenerPanel; import be.nikiroo.fanfix_swing.gui.utils.UiHelper; import be.nikiroo.fanfix_swing.images.IconGenerator; import be.nikiroo.fanfix_swing.images.IconGenerator.Icon; @@ -22,7 +22,7 @@ import be.nikiroo.fanfix_swing.images.IconGenerator.Size; * * @author niki */ -public class SearchBar extends JPanel { +public class SearchBar extends ListenerPanel { static private final long serialVersionUID = 1L; private JButton search; @@ -47,7 +47,7 @@ public class SearchBar extends JPanel { text.requestFocus(); if (realTime) { - fireActionPerformed(); + fireActionPerformed(getText()); } } }); @@ -64,7 +64,7 @@ public class SearchBar extends JPanel { clear.setVisible(!empty); if (realTime) { - fireActionPerformed(); + fireActionPerformed(getText()); } } }); @@ -74,7 +74,7 @@ public class SearchBar extends JPanel { @Override public void actionPerformed(ActionEvent e) { if (!realTime) { - fireActionPerformed(); + fireActionPerformed(getText()); } } }); @@ -89,7 +89,7 @@ public class SearchBar extends JPanel { clear.setVisible(false); text.requestFocus(); - fireActionPerformed(); + fireActionPerformed(getText()); } }); @@ -98,39 +98,6 @@ public class SearchBar extends JPanel { add(clear, BorderLayout.EAST); } - /** - * Adds the specified action listener to receive action events from this - * {@link SearchBar}. - * - * @param listener the action listener to be added - */ - public synchronized void addActionListener(ActionListener listener) { - listenerList.add(ActionListener.class, listener); - } - - /** - * Removes the specified action listener so that it no longer receives action - * events from this {@link SearchBar}. - * - * @param listener the action listener to be removed - */ - public synchronized void removeActionListener(ActionListener listener) { - listenerList.remove(ActionListener.class, listener); - } - - /** - * Notify the listeners of an action. - */ - protected void fireActionPerformed() { - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getText()); - Object[] listeners = listenerList.getListenerList(); - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == ActionListener.class) { - ((ActionListener) listeners[i + 1]).actionPerformed(e); - } - } - } - /** * Return the current text displayed by this {@link SearchBar}. *