made search field react on keypress
This commit is contained in:
parent
96bbef8bbd
commit
e165367133
@ -1,5 +1,6 @@
|
||||
package ch.hevs.isc.slopify_v2
|
||||
|
||||
import java.awt.event.{KeyEvent, KeyListener}
|
||||
import java.awt.{GridBagConstraints, GridBagLayout, LayoutManager}
|
||||
import java.util
|
||||
import javax.swing._
|
||||
@ -29,7 +30,11 @@ class GUI extends JFrame {
|
||||
})
|
||||
|
||||
val artistsSearchBar: JTextField = new JTextField()
|
||||
artistsSearchBar.addActionListener(_ => updateArtistsSearch())
|
||||
artistsSearchBar.addKeyListener(new KeyListener {
|
||||
override def keyTyped(keyEvent: KeyEvent): Unit = {}
|
||||
override def keyPressed(keyEvent: KeyEvent): Unit = {}
|
||||
override def keyReleased(keyEvent: KeyEvent): Unit = updateArtistsSearch()
|
||||
})
|
||||
|
||||
val col1Constraints: GridBagConstraints = new GridBagConstraints()
|
||||
col1Constraints.fill = GridBagConstraints.BOTH
|
||||
@ -94,11 +99,15 @@ class GUI extends JFrame {
|
||||
val songsSelectionModel: ListSelectionModel = songsTable.getSelectionModel
|
||||
songsSelectionModel.addListSelectionListener(e => {
|
||||
val row: Int = e.getFirstIndex
|
||||
try {
|
||||
val songName: String = songsTableModel.getValueAt(row, 0).asInstanceOf[String]
|
||||
val song: Option[Song] = curAlbum.get.getSongByTitle(songName)
|
||||
if (song.isDefined) {
|
||||
selectSong(song.get)
|
||||
}
|
||||
} catch {
|
||||
case e: ArrayIndexOutOfBoundsException => {}
|
||||
}
|
||||
})
|
||||
|
||||
val split1: JSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, col1, col2)
|
||||
|
Loading…
Reference in New Issue
Block a user