Java: How to Create a Label

A label is used to write text in an application, display title and interactive text. To make it, I will use the Swing method name “JLabel”. It’s easy to make and similar to a button. Start with the same syntax as a button:

JLabel label = new JLabel(“My first JLabel!”);
label.setBounds(0, 0, 200, 30);

frame.add(label);

You can Run your application and see the result!

Other Tutorial for your Level:
Java: How To Create an Organize New Project
Java: How to Create Button
Java: Create a Basic Application

 

Leave a comment