Generally there is a limitation on JLabel text formatting in swing. We can not apply some formatting in JLabel text.
Like:-
Applying bullets in text.
Write text in new line.
Making any text bold.
and may more you can try.
We can only change size, font and style of text using Netbeans or any IDE. But applying HTML tags in JLabel text, we can do more in text formatting.
Let's see how?
If you are using no IDE then use code like:-
jLabel18.setText("<html>
<p>\n
<ul style=\"list-style-type:square\">\n
<li> Users shall not play computer games on computers unless authorised by an authority.</li>\n
<li> Users shall not interfere or tamper with software configurations or any system data files.</li>\n
<li> Users shall not access or in any way alter another user`s files without authorisation.</li>\n
<li> Users shall not make use of computers to access or copy/playing any computer games, viruses, movies and music for personal use.</li>\n
<li> Do not run programs that continue to execute after you log off.</li>\n
<li><strong> Users must back up (e.g. on Pen Drive, Mail, Cloud etc) her data after each system use.</strong></li> \n
<li>There is no responsibility of University of the user’s data to be stolen, deleted or modified.</li>\n
<li> Downloading or installing programs on the hard drives is strictly prohibited without permission.</li>\n
<li> Do not use the computer for playing music or watching movies.</li>
</p>
</html>");
Like:-
Applying bullets in text.
Write text in new line.
Making any text bold.
and may more you can try.
We can only change size, font and style of text using Netbeans or any IDE. But applying HTML tags in JLabel text, we can do more in text formatting.
Let's see how?
If you are using no IDE then use code like:-
jLabel18.setText("<html>
<p>\n
<ul style=\"list-style-type:square\">\n
<li> Users shall not play computer games on computers unless authorised by an authority.</li>\n
<li> Users shall not interfere or tamper with software configurations or any system data files.</li>\n
<li> Users shall not access or in any way alter another user`s files without authorisation.</li>\n
<li> Users shall not make use of computers to access or copy/playing any computer games, viruses, movies and music for personal use.</li>\n
<li> Do not run programs that continue to execute after you log off.</li>\n
<li><strong> Users must back up (e.g. on Pen Drive, Mail, Cloud etc) her data after each system use.</strong></li> \n
<li>There is no responsibility of University of the user’s data to be stolen, deleted or modified.</li>\n
<li> Downloading or installing programs on the hard drives is strictly prohibited without permission.</li>\n
<li> Do not use the computer for playing music or watching movies.</li>
</p>
</html>");
output of this code will be:-
If you are using Netbeans then:-
Right Click on JLabel and Select Properties
In Properties select text
Press ok.
Now it is done.
No comments:
Post a Comment