1

I am using Nimbus look and feel in my Swing project.

Its displaying the excellent look in the project but JEditorPane is not displaying the proper font format when applying Nimbus look and feel

So is it possible to have multiple look and feels for single application? By default the project takes the look and feel applied on the main screen. Can it change the look and feel in between the project execution ?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
adesh singh
  • 1,727
  • 9
  • 38
  • 70
  • Possible duplicate: http://stackoverflow.com/questions/446056/can-i-use-two-different-look-and-feels-in-the-same-swing-application – MicSim Feb 06 '13 at 10:44
  • What do you mean by "not displaying the proper font format"? Can you provide a example? – MadProgrammer Feb 06 '13 at 10:48
  • I am displaying html files in jeditorpane the the font in jedtitorpane is not the same as it is actually in the original html files – adesh singh Feb 06 '13 at 10:52
  • @adeshsingh have you tried a different look and feel? – MadProgrammer Feb 06 '13 at 11:06
  • yes, this is possible,for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about `JFrame` and `JEditorPane` with hardcoded value for `JEditorPane`s content – mKorbel Feb 06 '13 at 11:09

1 Answers1

1

What you suggest is technically possible, but the approach is fragile for any but the most well-encapsualted default used by a well-behaved UI delegate implementation. In this example, a borrowed JTree icon is shown. For your application, the relevant key is "EditorPane.font". If you change it, some things to keep in mind:

  • Prefer a logical font family to a physical font, e.g. Font.SANS_SERIF or Font. DIALOG.

  • Consider using the deriveFont() method to alter the existing default.

  • Test extensively on your target platform(s).

  • Consider an alternate approach, where possible.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • +1 but I can see another issue there, not sure what (with Html styles, version and support in Java) OP meaning with `I am displaying html files in jeditorpane the the font in jedtitorpane is not the same as it is actually in the original html files` – mKorbel Feb 06 '13 at 14:58
  • @mKorbel: Ah, good point, thank you for commenting; HTML support is [limited](http://stackoverflow.com/a/6785121/230513) and fonts vary by platform. Maybe adesh singh can edit the question to clarify. – trashgod Feb 06 '13 at 17:08