Multiline Labels in awt (Java) 06/24/2011
UPDATE 20/1/2011: I have updated the source code to allow you to set the text colour and background colour of the returned panels. I have also added a .jar and read me so you can simply import the .jar into your project and start using the code, see multilinelabel_update.zip --- GUI's in Java can baffle people particularly when dealing with awt after having already learnt Swing. One thing that many people struggle with when dealing with awt is the lack of those extra features that Swing has added. In my case as a programming designer I wanted to display information in a label but I wanted to have it in a multiline format. Awt has no inbuilt multi-line label capacity, so I wrote a class that would allow me to split a given string string at a given maximum character width without splitting any words. You can download the .java file below. If you wish to use my code please acknowledge me and let me know how you have used it, I am always interested to know how and what it was used for. I have made it Java 2.0 & J2ME compatible, if you are looking to use it with a later Java library I have put some suggestions in the comments.
CommentsLeave a Reply | Code BlogAs much of my experience is code focused, I wasn't really sure how to go about demonstrating my code skills in a web portfolio. After much trial an error I decided to use a blog structure to show code examples and discussions of them. If you have any feedback or ideas let me know.
CategoriesAll | ||||||||||||
