Skip to content

Commit 398b2ce

Browse files
Merge pull request #62 from EatSleepProgramRepeat/46-make-enter-preform-a-search
made enter search
2 parents 48ca792 + 94d033f commit 398b2ce

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/com/CDPrintable/ProgramWindow.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ public void mouseClicked(MouseEvent e) {
111111
// CD Search Panel set up
112112
cdSearchPanel.setBorder(BorderFactory.createTitledBorder("Search"));
113113

114+
// Make the input field
114115
JTextField searchField = new JTextField(15);
115116

117+
// Search type combo box set up
116118
JComboBox<String> searchTypeComboBox = new JComboBox<>(new String[] {"CDStub", "Artist", "Release"});
117119

118120
// Search button and event listener setup
119121
JButton searchButton = new JButton("Search");
122+
120123
searchButton.addActionListener(_ -> {
121124
if (searchTypeComboBox.getSelectedItem() == null) {
122125
return;
@@ -175,6 +178,9 @@ public void mouseClicked(MouseEvent e) {
175178
});
176179
});
177180

181+
// Set up enter key and text box
182+
searchField.addActionListener(_ -> searchButton.doClick());
183+
178184
cdSearchPanel.setLayout(new FlowLayout());
179185
cdSearchPanel.add(searchTypeComboBox);
180186
cdSearchPanel.add(searchField);

0 commit comments

Comments
 (0)