I am a beginner at Java and coding. I don't know if this problem is occurring because I forgot something in the code or something is not correct in the code.
I have already tried looking through all the questions on Stack Overflow that are similar to my question and none of them helped me. I've been doing trial and error but still cannot fix it.
import javax.swing.JFrame;
import javax.swing.JLabel;
public class JLabel {
public static void main(String args[]) {
JFrame myFrame = new JFrame();
String myTitle = "Blank Frame";
JLabel label1 = new JLabel("Test");
`````
label1.setText("Test Text");
`````
myFrame.setTitle(myTitle);
myFrame.setTitle(900,600);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setVisible(true);
}
}
At 'label1.setText("Test Text");' is where the problem is. My goal for this code is to create a window that has some text in it. Hopefully, the fix is simple and not as complicated as many codes.