Created
June 24, 2016 13:05
-
-
Save bragboy/6426e48428d886fe7eb32fb675878c33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dsa.tries; | |
import java.awt.Dimension; | |
import java.awt.Toolkit; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JOptionPane; | |
import javax.swing.JPanel; | |
import javax.swing.JTextField; | |
public class TrieTestFrame extends JFrame { | |
private static final long serialVersionUID = 1L; | |
private JPanel basePanel = new JPanel(); | |
private JTextField textField = new JTextField(20); | |
private JButton button = new JButton("Check"); | |
public TrieTestFrame(){ | |
designUI(); | |
} | |
private void designUI(){ | |
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
this.setTitle("TRIE Test"); | |
button.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
if(TrieLoader.trieDSA.search(textField.getText())){ | |
JOptionPane.showMessageDialog(basePanel, "The word you entered exist!!"); | |
}else{ | |
JOptionPane.showMessageDialog(basePanel, "The word you entered does not exist!!","Error",JOptionPane.ERROR_MESSAGE); | |
} | |
} | |
}); | |
basePanel.add(textField); | |
basePanel.add(button); | |
add(basePanel); | |
this.setSize(400,100); | |
Toolkit tk = Toolkit.getDefaultToolkit(); | |
Dimension screenSize = tk.getScreenSize(); | |
int screenHeight = screenSize.height; | |
int screenWidth = screenSize.width; | |
setLocation(screenWidth / 2 - 200, screenHeight / 2 - 50); | |
this.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment