gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/SearchBar.java
| a9b2a64 | 1 | package gdxstudio; |
| a62d533 | 2 | import java.awt.Dimension; |
| a62d533 | 3 | import java.awt.event.ActionEvent; |
| a62d533 | 4 | import java.awt.event.ActionListener; |
| a62d533 | 5 | |
| a62d533 | 6 | import javax.swing.JButton; |
| a62d533 | 7 | import javax.swing.JPanel; |
| a62d533 | 8 | import javax.swing.JTextField; |
| a62d533 | 9 | |
| a62d533 | 10 | import web.laf.lite.layout.HorizontalFlowLayout; |
| a62d533 | 11 | import web.laf.lite.utils.UIUtils; |
| a62d533 | 12 | |
| a62d533 | 13 | final public class SearchBar extends JTextField {
|
| a62d533 | 14 | private static final long serialVersionUID = 1L; |
| a62d533 | 15 | static int index = 0; |
| a62d533 | 16 | |
| a62d533 | 17 | public SearchBar(){
|
| a62d533 | 18 | UIUtils.setRound(this, 2); |
| a62d533 | 19 | UIUtils.setDrawFocus(this, false); |
| a62d533 | 20 | UIUtils.setInputPrompt(this, "Search"); |
| a62d533 | 21 | UIUtils.setShadeWidth(this, 0); |
| a62d533 | 22 | setPreferredSize(new Dimension(280, 22)); |
| a62d533 | 23 | |
| 7c84877 | 24 | JButton searchUpBtn = Style.createToolButton("SearchUP", "up", new ActionListener(){
|
| a62d533 | 25 | @Override |
| a62d533 | 26 | public void actionPerformed(ActionEvent arg0) {
|
| a62d533 | 27 | if(Content.currentView.equals("Editor")){
|
| a62d533 | 28 | Editor.context.setSearchForward(false); |
| a62d533 | 29 | Content.editor.find(getText()); |
| a62d533 | 30 | } |
| a62d533 | 31 | } |
| a62d533 | 32 | }); |
| 7c84877 | 33 | UIUtils.setLeftRightSpacing(searchUpBtn, 0); |
| 7c84877 | 34 | UIUtils.setUndecorated(searchUpBtn, true); |
| 7c84877 | 35 | JButton searchDownBtn = Style.createToolButton("SearchDown", "down", new ActionListener(){
|
| a62d533 | 36 | @Override |
| a62d533 | 37 | public void actionPerformed(ActionEvent arg0) {
|
| a62d533 | 38 | if(Content.currentView.equals("Editor")){
|
| a62d533 | 39 | Editor.context.setSearchForward(true); |
| a62d533 | 40 | Content.editor.find(getText()); |
| a62d533 | 41 | } |
| a62d533 | 42 | } |
| a62d533 | 43 | }); |
| 7c84877 | 44 | UIUtils.setLeftRightSpacing(searchDownBtn, 0); |
| 7c84877 | 45 | UIUtils.setUndecorated(searchDownBtn, true); |
| 7c84877 | 46 | |
| 7c84877 | 47 | JPanel updownPanel = new JPanel(new HorizontalFlowLayout(0)); |
| 7c84877 | 48 | updownPanel.add(searchUpBtn); |
| 7c84877 | 49 | updownPanel.add(searchDownBtn); |
| 7c84877 | 50 | updownPanel.setOpaque(false); |
| 7c84877 | 51 | UIUtils.setUndecorated(updownPanel, true); |
| 7c84877 | 52 | UIUtils.setTrailingComponent(this, updownPanel); |
| a62d533 | 53 | } |
| a62d533 | 54 | } |