안녕하세요, Groovy의 GUI 레이블에 이미지를 추가하는 데 문제가 있습니다. 누구든지이 일을 할 수있는 코드를 도울 수 있습니까? 나는 도처에 수색 해 왔으며 답을 찾지 못했습니다. 나는 그것을 끝내지 못하는 프로젝트를 끝내려고 노력하고있다.Groovy의 GUI에 이미지 추가
// add a text panel
def mainPanel = {
sB.panel(layout : new BorderLayout(), background: java.awt.Color.LIGHT_GRAY){
label(text: 'Welcome to your closet', horizontalAlignment: JLabel.CENTER,
constraints : BorderLayout.CENTER, icon: ImageIcon('/home/*****/Documents/ComputerScience/CS315/icons/create.png'))
buttonPanel()
}
}
내가 오류는 다음과 같습니다 :
label(text: 'Welcome to your closet', horizontalAlignment: JLabel.CENTER,
constraints : BorderLayout.CENTER, icon: imageIcon(resource: '/home/*****/Documents/ComputerScience/CS315/icons/create.png'))
buttonPanel()
:
Caught: groovy.lang.MissingMethodException: No signature of method: GUI.ImageIcon() is applicable for argument types: (java.lang.String) values: [/home/*****/Documents/ComputerScience/CS315/icons/create.png]
groovy.lang.MissingMethodException: No signature of method: GUI.ImageIcon() is applicable for argument types: (java.lang.String) values: [/home/*****/Documents/ComputerScience/CS315/icons/create.png]
at GUI$_closure11_closure119.doCall(ClosetGUI.groovy:888)
다음 수정을 사용하여 내 GUI 여기 을 만들 SwingBuilder을 사용하고
내가 시도 것입니다
다음 오류가 발생합니다.
Caught: java.lang.RuntimeException: Failed to create component for 'imageIcon' reason: java.lang.RuntimeException: In imageIcon the value argument 'null' does not refer to a file or a class resource
java.lang.RuntimeException: Failed to create component for 'imageIcon' reason: java.lang.RuntimeException: In imageIcon the value argument 'null' does not refer to a file or a class resource
at GUI$_closure11_closure119.doCall(ClosetGUI.groovy:888)
아무 도움도 없을 것입니다. 감사합니다!
당신이 몇 가지 코드를 게시 할 수 있습니까? GroovyFX를 사용하고 있습니까? 그네? SwingBuilder? 너 뭐 해봤 니? 무슨 오류있어? –
죄송합니다. 지금 SwingBuilders를 사용하고 있으며 코드를 게시 할 예정입니다. – ola
대문자 ImageIcon 대신 소문자 imageIcon을 사용해야합니다. –