72 lines
1.8 KiB
Java
72 lines
1.8 KiB
Java
package nt.UI.tests;
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.UIManager;
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
|
|
|
import nt.UI.control.JSearchBar;
|
|
import nt.UI.control.JSearchTextField;
|
|
import nt.UI.control.interfaces.SearchBarFinder;
|
|
import javax.swing.BoxLayout;
|
|
import java.awt.Component;
|
|
import java.util.Arrays;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
import javax.swing.Box;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JTextField;
|
|
|
|
public class UITestMain extends JFrame{
|
|
|
|
private static final boolean DEBUG_LAF = false;
|
|
|
|
public static void main(String[] args) {
|
|
if(DEBUG_LAF) {
|
|
try {
|
|
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
|
} catch (UnsupportedLookAndFeelException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
UITestMain frame = new UITestMain();
|
|
frame.setVisible(true);
|
|
}
|
|
|
|
public UITestMain() {
|
|
setSize(400,400);
|
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
|
getContentPane().add(new JSearchBar(new SearchBarFinder() {
|
|
|
|
@Override
|
|
public String[] getSearchResults(String token) {
|
|
List<String> list = Arrays.asList("a aa aaa aaaa b bb bbb bbbb bbbbb ab aabb bbaa baba".split(" "));
|
|
LinkedList<String> results = new LinkedList<>();
|
|
for(String tok : list) {
|
|
if(tok.startsWith(token)) {
|
|
System.out.println(tok + " " + token);
|
|
results.add(tok);
|
|
}
|
|
}
|
|
return results.toArray(new String[0]);
|
|
}
|
|
}));
|
|
|
|
Component verticalStrut = Box.createVerticalStrut(300);
|
|
getContentPane().add(verticalStrut);
|
|
|
|
JButton btnBtn = new JButton("btn");
|
|
getContentPane().add(btnBtn);
|
|
|
|
JSearchTextField searchTextField = new JSearchTextField();
|
|
getContentPane().add(searchTextField);
|
|
|
|
searchTextField.requestFocus();
|
|
}
|
|
|
|
}
|