Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on JOptionPane doesn't show; application combines Swing and console.
Post
JOptionPane doesn't show; application combines Swing and console.
+1
−1
What is wrong in the following code:
package oren;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
double x,y,z;
Scanner scanner = new Scanner(System.in);
System.out.println("what are the x and y side of the triangle");
x = scanner.nextDouble();
scanner.nextLine();
y = scanner.nextDouble();
scanner.nextLine();
scanner.close();
JOptionPane.showMessageDialog(null, Math.sqrt(x*x + y*y));
}
}
For some reason the JOptionPane.showMessageDialog doesn't show.
However, there are no error messages.
I am using Eclipse and Java 21.

2 comment threads