0
형태 파라미터를 취합니다클래스 JComboBox에 내가 내 청취자에 JComboBox의 인스턴스의 값을 얻으려면
object NoteListener extends ActionListener {
def actionPerformed(e:ActionEvent):Unit = {
println("Source: " + e.getSource.asInstanceOf[JComboBox].getValue)
}
}
을 그리고 난이 오류를 얻을 : 내가 어떤 매개 변수를 전달하려고 할 때
[error] .../test.scala:30: class JComboBox takes type parameters
[error] println("Source: " + e.getSource.asInstanceOf[JComboBox].getValue)
을 :
[error] .../test.scala:30: ']' expected but '(' found.
[error] println("Source: " + e.getSource.asInstanceOf[JComboBox(Array)].getValue)
버그입니까, 아니면 내 무지입니까?
저는 scala에 대해서는 모르지만 Java 7의 'JComboBox'(및 다른 Swing 클래스)에 대한 변경과 관련이 있습니다. 이는 일반적인 매개 변수 (예 : 유형 매개 변수)로 변경되었습니다. –
나는 바보입니다. "[]"대신 "()"을 사용했습니다. asInstanceOf가 아니면 안된다 [JComboBox [Array [java.lang.Object]]] – ciembor