Results 1 to 3 of 3
Thread: Changing text colour in code
- 04-29-2009, 03:11 AM #1
Changing text colour in code
On the press of the help button this code is running
As usual the text is black, however I wondered if it was possible to change the following only to red leaving the rest blackJava Code:if(evt.getSource()==cmdHelp); { optPane1.showMessageDialog(this, " You can use your mouse or tab key to navigate\n"+ " our body mass calculator.\n\n"+ " New button, this will overwrite all previous\n" + " files\n\n"+ " Add Record, enables you to add a new member\n" + " to the records only after creating new file.\n\n"+ " Search button, enter your membership number \n" + " click search to find member details.\n\n"+ " Update Button, Search for the appropriate record\n"+ " by membership number, amend the details\n"+ " then click the update button\n\n"+ " Select Imperial or Metric for the measurements,\n" + " enter the height and weight then click convert\n\n"+ " The default measurements are metric, if you \n"+ " select imperial using the radio button you \n"+ " will be advised."+ " \n","User Guide",optPane1.INFORMATION_MESSAGE);}
Thanks in advanceJava Code:New button, this will overwrite all previous\n" + " files\n\n"+
- 04-29-2009, 03:24 AM #2
First, I assume optPane1 is some sort of JOptionPane. Good practice says to invoke static methods using the class name, not through an instance.
You can use JOptionPane.showOptionDialog to display any sort of JComponent in the message parameter. You could build your message in a JPanel using JLabel's and set some of the JLabel's color to red. Or, you could use one of the fancier text components and make it read-only. Essentially, you have a lot of options.
- 04-29-2009, 03:32 PM #3
You should be able to manipulate the string with html...
I am pretty sure that you can do this for any text that goes into a component... I use it alot for my tooltips...Java Code:String myString="<html><body><font color=red>This is some red text...</font></body></html>"; .
Last edited by markw8500; 04-29-2009 at 03:46 PM.
Who Cares... As Long As It Works...
Similar Threads
-
[SOLVED] Change text colour on conditions in netbeans
By dbashby in forum New To JavaReplies: 0Last Post: 03-26-2009, 01:23 AM -
manual BMP rendering colour issues
By Goseph in forum AWT / SwingReplies: 0Last Post: 02-24-2009, 08:26 PM -
POI changing text to a form label
By natt in forum Advanced JavaReplies: 2Last Post: 09-19-2008, 10:49 AM -
Changing the color of text
By Lang in forum New To JavaReplies: 1Last Post: 11-04-2007, 09:51 AM -
Changing plugins source code
By yakupemre in forum EclipseReplies: 1Last Post: 08-15-2007, 09:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks