Questions about using namedWindow() and imshow() in Java

Is there a way to solve the problem I encountered? Or is it a bug in the code that needs to be addressed?