1
작은 대화 상자를 만들고 있습니다. gradble 빌드 스크립트에서 Groovy를 사용하고 있습니다. 대화 상자는 JList, JTextField 및 JButton으로 구성됩니다.그루비에서 JList의 보이는 행을 제한하는 방법
목록에는 파일 이름이 채워집니다. 많은 파일이 있으므로 목록을 통과하기 위해서는 5 개의 파일을 함께 표시해야합니다. visibleRowCount를 설정하려고했지만 여전히 모든 행을 표시합니다.
new SwingBuilder().edt {
dialog(modal: true, // Otherwise the build will continue running before you closed the dialog
title: 'Enter program name',// Dialog title
alwaysOnTop: true, // pretty much what the name says
resizable: true, // Don't allow the user to resize the dialog
locationRelativeTo: null, // Place dialog in center of the screen
pack: true, // We need to pack the dialog (so it will take the size of it's children
show: true // Let's show it
) {
vbox { // Put everything below each other
label(text: "Program Name:")
list(id:"programName", items: progNames, visibleRowCount: 8)
label(text: "Start Rule Name:")
input = textField(id: 'ruleName', text: startRuleName)
button(defaultButton: true, text: 'OK', actionPerformed: {
testProgram = programName.selectedValuesList
startRuleName = ruleName.text
dispose() // Close dialog
})
}
}
}
보이는 행 수를 어떻게 제한합니까?
당신이'스크롤에 포장 시도 되세요 {목록 ...}' –