• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Makefile syntax highlighting in Jforms using JEditorPane?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working with a JEditorPane in Java using JForms which displays a file a user opens when it is clicked on. The JEditorPane displays that file and at the moment has syntax highlighting for many files such as c,c++ file,java, python etc.
I'm going through the code and I can see where it initializes this code to highlight the syntax for example lines I found in a switch statement depending on what the user opens


and then the JEditorPane sets the content type with the line

So what I did was modify the existing code to recognize makefiles. I added all the necessary code for the new makefile filetype and just to make sure it was correctly working I used cpp syntax highlighting to make sure I coded it right and yes all my makefiles were being opened in the editor pane using c++ highlighting although it is isn't highlighting the right things as expected.
Now I added a new contentType to see if it would work replacing the lines that used c++ syntax highlighting in my makefiles with

and also

just to see when I opened a makefile it would syntax highlight correctly and it didn't.

I dug deeper into the code specifically the setContentType method and saw that it is compiled code of the JEditorPane class. So I'm guessing that all these other filetypes and their syntax highlighting capabiities are built in java and for makefile syntax highlighting to work, I'm going to have to use custom code?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!