I am very new to jshell and Java and am having an issue with the jshell edit pad not accepting or transferring code snippets to jshell. When I enter the code snippet below and press "Accept" and "Exit" nothing is happening. No error messages are displayed in the jshell terminal window and I do not get the window displayed on my screen. The code seems not to be running.
import javax.swing.*;
JFrame window = new JFrame("Another New Window");
JPanel panel = new JPanel();
JButton button = new JButton("Click me!");
panel.add(button);
window.add(panel);
window.setSize(300,100);
button.addActionListener(e -> System.out.println("Ouch! You clicked me!"));
window.setVisible(true);
However, when I enter this same code snippet directly into the jshell window (command prompt), the window appears as it should. What could be going wrong? What mistakes am I making?
I have noticed that I am able to get the results of simple operations, such as 2+2;
to show the answer in the jshell console window after pressing "Accept", but actual code entered into the default edit pad seems not to run at all.
I am running Windows 10 and I have the latest versions of JDK 8 and 10 installed.
Thank you for your assistance!