JLabel -example

Creating a JLabel with Text Example

Below code creates a Simple JLabel with Text Example using JLabel() constructor method.Note that JLabel class has several methods.  

Output:

setEnabled

Check whether a JLabel is Enabled or Visible.

JLabel.setEnanbled() methods enable a JLabel or make it visible in it container.If you set false, the JLabel is not visible and if set truth, the JLabel is visible. Below code creates two JLabels, one is enabled and the other is not enabled.

How to overload java methods by changing data type

How to overload java methods by changing data type

Below code shows how to overload java method by changing data type.See also Overloading java methods by changing the number of arguments.  

Output

How to overload java methods by changing number of arguments

How to overload java methods by changing number of arguments

The main reason why programmers overload methods are for easier readability.Think of a scenario where you have a method to multiply two numbers and another method multiply three numbers.These methods will have different names.Instead of using different names, java overloading allows us to use the…

Java program that takes two numbers as input from a user and displays the product of two numbers.

Below Java program code takes two integers from the user , multiplies  them and display

Java program to divide two numbers and print on the screen

Below java program code divided two numbers and prints the output on the screen.

Write a Java program to print the sum of two numbers

Below java program code prints sum of two numbers and displays the result.

Write a Java program to display “Hello world”

Below java program code is used to display “Hello World”  and print your name in a seperate line.

How to connect to a mysql database using com.mysql.jdbc.Driver

Below code shows how to connect to a MySQL database using com.mysql.jdbc.Driver.

Java JLabel setBorder() Method Example

Java JLabel setBorder () Method Example

Below code shows how to use Java JLabel setBorder ()  Method Example

OutPut: See also: Java JLabel getText and JTextField setText methods