Welcome!

Jim Crafton

Subscribe to Jim Crafton: eMailAlertsEmail Alerts
Get Jim Crafton via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Top Stories by Jim Crafton

Last month we discussed the use of Swing's Document model to create a syntax-highlighting Document model that we could just plug into JTextPane and use. This month we'll continue with that and add complete support for comments, strings and numbers. We'll also cover how easy it is to actually use the model we've developed, and test things out as we go along. To start things out let's try and use what we have so far. If we look at the code below we can see that plugging the Document we've created into a JTextPane component is quite easy. Defining the keywords is also very easy. JTextPane editor = new JTextPane(); CodeDocument doc = new CodeDocument(); Vector keywords = new Vector(); keywords.addElement("abstract"); keywords.addElement("boolean"); ... doc.setKeywords(keywords); editor.setDocument(doc); We could have just created the CodeDocument on the fly and passed it in as ... (more)

Components, and Creating a Custom Property Editor

This column discusses property editors and how to implement one for Java -specifically, how to make one work for our CodeDocument class. When last we talked, we saw how to build a CodeDocument class, but it wasn't something we could work with in a visual designer like JBuilder, say, or Visual Cafe. In this column we'll build a special case of the JTextArea component and add some specialty properties and property editors to support the CodeDocument class we worked on before. The code listings at the end of the article are excerpted from the complete code, which you can download fr... (more)

Text Controls by Swing

When Java first came out, one of its acknowledged weaknesses was the lack of an advanced set of GUI components. This was especially evident in the text controls, which lacked many of the advanced features found in the native text controls of operating systems such as Windows. With the release of the Java Foundation Classes (also known as Swing), Java finally had a robust and sophisticated collection of controls, especially text controls. With this in mind, this series of articles will show how to build a simple syntax, with emphasis on text control using Swing's Model View Controll... (more)

Reflecting a Bean onto a Table

Originally I planned to continue with the syntax-highlighting CodeDocument component, but I decided to switch gears and discuss some neat uses for the JTable component that comes with Swing (my apologies go out to all those weeping in the aisles, anxiously awaiting more syntax-highlighting code...oh, just a second, let's dab the tears away before continuing). One of the cool features of the JTable component is its ability to be customized, right down to the individual table cell. This feature, plus another unspeakably cool feature of Java itself (called reflection, but more on th... (more)

A Return to Reflection

When we last talked, I promised to finish up the CodeDocument class I'd so abruptly left behind back in July (JDJ Vol. 4, issue 7). Now, due to millions of desperate letters from fans around the globe, I've decided to finish off the series in this article, tackling reflection once again and ending with a text component that supports syntax highlighting and a simplified version of something similar to Borland's Code Insight. Along the way we'll see a few more tricks that JTextArea can do, and in general we'll just go hog wild in code! A Refresher on Reflection Those of you who rea... (more)