JButton disappear if I comment a bit of code

JButton disappear if I comment a bit of code

if I comment the code as shown the JButtons disappear

if I comment the code as shown the JButtons disappear

public class analisi_spesa {

public static void main(String[] args) {

JFrame mainFrame = new JFrame("Java SWING Examples");
mainFrame.setLayout(new GridLayout(3, 1));

/* JLabel headerLabel = new JLabel("headerLabel",JLabel.CENTER ); JLabel statusLabel = new JLabel("statusLabel",JLabel.CENTER);
statusLabel.setSize(350,100); */ mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); }

JPanel controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());

/* mainFrame.add(headerLabel); mainFrame.add(controlPanel); mainFrame.add(statusLabel); */


// headerLabel.setText("Control in action: Button");

JButton okButton = new JButton("OK");
JButton submitButton = new JButton("Submit");
JButton cancelButton = new JButton("Cancel");


okButton.addActionListener(new ButtonClickListener()); 
submitButton.addActionListener(new ButtonClickListener()); 
cancelButton.addActionListener(new ButtonClickListener()); 





I wish they were shown as I don't comment the code. I took this example from https://www.tutorialspoint.com/swing/swing_event_handling.htm thank you all, I'm waiting for the answers.


Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Java Core (2020) | Java for beginners | Brush up your Java Skills | Get Hired

In this video we will learn about all the major concepts that come under Java Core . The course is very carefully designed and is made with keeping simplicit...

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Top 10 Java Frameworks For Web App Development: 2020 Edition

Java Frameworks are the pre-written code body through which you are enabled to add your own code. There are numerous Java frameworks that have different leading features, on the basis of the same here, I will discuss Top 10 JAVA Frameworks For Web App Development 2020-2021. 

How Java Became The Best Career Option for IT Jobs in 2020?

Join CETPA, India's best institute for Java online training and Certification Course. Enroll now to learn Core to Advanced Java & avail 50% discount on Java Online Course with Certificate.