|
||||||
| Java Tutorials Tutorials and Code for Java |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
One useful feature of Swing GUI's many people overlook is the ability to use simple HTML tags within swing components. This tutorial assumes you know how to create a GUI in swing and add components. If you do not know how to do this, it is a good idea to read one of my previous tutorials. You can view my Tutorial Index here: http://forum.codecall.net/java-tutor...ial-index.html
Lets first create a basic GUI with a JButton and JLabel: Java Code:
But what if you want the text on the button to be a different color? You can use the HTML font tags inside the JButton string parameter. Such as: Java]JLabel label1 = new JLabel("<html><font color='#FF0000'>Red Text</font>" +
"<br /><font color='#00FF00'>Blue Text</font></html>");[/highlight] Not only can you modify fonts, you can also insert images: [highlight="Java Code:
There is much more you can do with HTML, just note, when you do insert HTML into a componnents string paramater, you need to surround the HTML with the opening and closing HTML tags <html></html> and you need to use single quotes since the entire string is bound by double quotes. Java Code:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| About HTML | Onur | Tutorials, Classes and Code | 0 | 08-28-2007 06:13 PM |
| HTML Basic Formatting | clookid | Tutorials, Classes and Code | 14 | 03-06-2007 03:10 PM |
| HTML Introduction | clookid | Tutorials, Classes and Code | 5 | 01-08-2007 09:43 PM |
| What is HTML, DHTML and XHTML? | Lop | HTML Programming | 5 | 08-09-2006 11:00 AM |
| Removing HTML from a String using ColdFusion | roger | ASP, ASP.NET and Coldfusion | 0 | 05-11-2006 10:19 PM |