The Artima Developer Community
Sponsored Link

Java Answers Forum
Varying Fonts on a Panel

4 replies on 1 page. Most recent reply: Jul 31, 2005 11:09 PM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Varying Fonts on a Panel Posted: Jul 28, 2005 12:34 AM
Reply to this message Reply
Advertisement
Give me a clue on how I can set the Font for one word on a Panel and the next word appearing in a different font/font
color in the same panel.

E.g. From an HTML perspective:

<font color="black">Please click </font> <font color="red">here</font>

I want this in a JPanel though.

Please give me steps towards how to find the solution.

I'll run a Google, though I doubt I'll find anything.

Tx in advance.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Varying Fonts on a Panel Posted: Jul 28, 2005 5:30 AM
Reply to this message Reply
Actually its OK, using HTML tags works on JPanels,
(besides you can always use setForeground)
what I actually wanted was manipulation of fonts in
a JOptionPane.

Any ideas?

Tx in advance.

Kondwani

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Varying Fonts on a Panel Posted: Jul 28, 2005 5:46 AM
Reply to this message Reply
> Give me a clue on how I can set the Font for one word on a
> Panel and the next word appearing in a different
> font/font
> color in the same panel.
>
> E.g. From an HTML perspective:
>
> <font color="black">Please click </font> <font
&gt; color="red">here</font>
>
> I want this in a JPanel though.
>
> Please give me steps towards how to find the solution.
>
> I'll run a Google, though I doubt I'll find anything.
>
> Tx in advance.

Actually sorry, my bad its actually only <html>
that I can think of that can alter two words or
letter colors in the same pain (atleast without
creating your own customized library.

I'm still looking for this type of functionality
for a JOptionPane



String mesg;
mesg = "<html><font color=red>this is red</font>
<font color=green>this is green</font></html>";
JOptionPane.showConfirmDialog(parent, mesg, "Confirm",
JOptionPane.YES_NO_OPTION);



Does not work! Help with other suggestions please.

barron

Posts: 13
Nickname: toniblair
Registered: May, 2005

Re: Varying Fonts on a Panel Posted: Jul 29, 2005 1:43 PM
Reply to this message Reply
One option is for you to simply create your own Dialog that functions similarly to the JOptionPanes.
With this approach you could add whatever you'd like to your dialog. You could add a JEditorPane which can intepret html and now format your text however you like...Add any component that you like. If you need Buttons, add a panel with buttons. You could create a method that shows teh dialog and returns a value based on which buttons where selected...

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Varying Fonts on a Panel Posted: Jul 31, 2005 11:09 PM
Reply to this message Reply
Sounds great, but unfortunately I'm working on
a large scale system. One of the warning,
notification UI modules has been coded with
a JOptionPane, I would like to extend its
functionality with out introducing new classes
and making the code extremely bulky and down
the road probably hard to maintain.

Tx for the response though.

Spike

Flat View: This topic has 4 replies on 1 page
Topic: to build GUI like BlueJ Previous Topic   Next Topic Topic: Solve this problem if you can

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use