use of com.frostwire.gui.searchfield.SearchField in project frostwire by frostwire.
the class LibrarySearch method setupUI.
protected void setupUI() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
setMinimumSize(new Dimension(200, 20));
setPreferredSize(new Dimension(200, 20));
statusLabel = new JLabel();
statusLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 0));
add(statusLabel, BorderLayout.CENTER);
searchField = new SearchField();
searchField.setSearchMode(SearchMode.INSTANT);
searchField.setInstantSearchDelay(50);
searchField.setPrompt(I18n.tr("Search in Library"));
Font origFont = searchField.getFont();
Font newFont = origFont.deriveFont(origFont.getSize2D() + 2f);
searchField.setFont(newFont);
searchField.addActionListener(new ActionListener() {
private SearchLibraryAction a = new SearchLibraryAction();
@Override
public void actionPerformed(ActionEvent e) {
if (searchField.getText().length() == 0) {
a.perform(".");
} else {
a.actionPerformed(null);
}
}
});
searchField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
// TODO Auto-generated method stub
}
@Override
public void focusGained(FocusEvent e) {
// if there's nothing selected for search, select Audio directory holder.
if (LibraryMediator.instance().getLibraryExplorer().getSelectedDirectoryHolder() == null && LibraryMediator.instance().getLibraryPlaylists().getSelectedPlaylist() == null) {
LibraryMediator.instance().getLibraryExplorer().selectAudio();
}
}
});
}
Aggregations