Skip to main content

Simple Client Applications

11 replies [Last post]
Joined: 2003-06-13

What surprises me about Java on the desktop is that there are very few simple clean example of it in use that are fundamental.

I've taken it upon myself to write a Java application like Mac OS X's TextEdit. I thought it functionally is a nice simple example of an application where Swing would support all the necessary elements that I would need to put into my code.

I have to admit, that I learn best by example. I went looking for code snippets here and there that cover all the aspects of development that I would need.

Undo/Redo features. RTF/HTML/Text management. Document save/dirty/save as/untitled management.

Other than some exceptionally complex examples like Eclipse's editors or JEdit or the like. There are very few *simple* examples. You'd think University students would be churning these things out by the boat load.

Simple Paint Programs. Simple Text Editors. Simple Spreadsheet Programs. Vector Graphic Editors etc....

Yet... Really, there isn't that much....

Anyone care to prove me wrong?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-21

> Simple Paint Programs. Simple Text Editors. Simple
> Spreadsheet Programs. Vector Graphic Editors etc....
> Yet... Really, there isn't that much....
> Anyone care to prove me wrong?

Vector Graphics Editors? I've written one - as a student... :)
I though about putting it somewhere, but lacked motivation ;)

Joined: 2003-06-21

Just for the record, about a year ago I put up this editor as a webstartable application:

It's on my totally unrelated project, and seems to be a violation of sourceforge's rules, so it might disappear without a warning, but that's the only web page accessible to me ;)

Joined: 2004-07-23

Yes. Many of us have been ranting about the lack of support for Swing over the past few years. I blame the vendor ladened JCP for steering Sun toward focusing on server side enhancements and the vendors themselves for not stepping up and supporting the framework until recently. Now support is really picking up with Netbeans and many open source projects, such as SwingLabs, providing a lot of missing features. Also, JSR-295 Beans Binding and JSR-296 Swing Application Framework should fill in a lot of missing pieces as well as JDBC 4.0 features in Java 6 and the Persistence API. If you want to get your feet wet with some really good examples, then I suggest the Java Tutorial and the JGoodies frameworks. Many great examples of how to do most things can be found there.


Joined: 2003-06-13

What I'm essentially saying is that there is no application example that is sufficient but not extranious. A complete but basic application. I think a text editor would be a fine example. The notepad sample code isn't complete. It doesn't have copy/paste (I don't believe) nor does it have undo/redo. It would also be great to have a multi-document example.

I would think that an "advanced" framework like Swing, a fully featured but simple text editor would be relatively trival to implement. (In my own endevors I have found this not to be the case but I'm working on it).

People have often talked of putting together their own template than they then use in subsequent applications that they modify. I'd love to see that kind of structure that I may too be allowed to more easily define these.

At the moment, I'm also trying to put my money where my mouth is. I don't have much spare time but I'm trying to build myself an application framework as well as a simple complete text editor. Not because I think the world needs more text editors but simply because I think the example of it needs to exist.

Infact, I've gone so far as to write an implementation of TextEdit. A Mac OS X RTF/HTML/TXT editor that is quite plain but has sufficient bredth to be a useful example for people.

I am, however, stumbling on trying to structure a few things that it would be useful to see how others might do it.

I see Swing as an interesting UI toolset. I've been toying with it for a surprisingly long time but I've never really built a full application with it. Something I'm trying to change.

Thanks for the responses though. I find the discussion quite interesting non the less.

Joined: 2003-06-13

I certainly applaud your efforts. There's always work to be done here.

But the reason I fixated on the Order Entry application is simply because I think that's what the majority of applications that are being written today do, and therefore an example of such an application would have a wider impact on actual Swing skillsets in the development community, specifically the business/back office community.

I appreciate that it's difficult to do a "complete" program, and then keep it manageable. To me, literally a book could be written about something "as simple" as an Order Entry application. Discussing the Swing topics involved, the design patterns involved and the choices made, why they were made, and perhaps alternatives.

It would be an interesting case study.

On the surface, it sounds really dull. I mean, it's a CRUD application for crying out loud, but in truth it's an interesting example of design, and it's the design of something most everyone can relate to.

I think there are several nuggets of wisdom that could be pulled from disecting a solid back office business application.

Joined: 2004-11-25

I think developing Simple Cleint Applications in Swing is just 2 much work(after i come 2 know smalltalk( VW & Squeak )).Java is also borring langauge for Rapid Development because of its static nature and slow development cycle.

Most Smart programmers move on to other smart( i should say dynamic ;) languages early on So u dnt see good client-side applications.

But still I do love Java.

Joined: 2004-02-09

I think you're posing more than one question. People have created these "simple" apps, but the truth is it's not 1985 anymore, and those "simple" apps lack a compelling reason to use them. Most of us already have chosen our text editors, paint tools, etc. a long time ago. I try out new software all the time, but if there are too many little things that bug me I move on.

jEdit is an example of one that's compelling, but it's been in development a long time and it's no longer simple (in the internals). Slava and others seem to have struggled with a whole range of issues, and have developed a pretty large user base to report bugs and submit patches. But it's also compelling, for me, because it solves some annoyances like using the proper encodings when reading files, which is the last thing I want to think about when opening and editing a file.

There is a "Notepad" example in the Swing demos, shipped with the JDK, but I'd never use it--because I gave up on Notepad a long time ago as well. I use Editplus or jEdit or vi for text files, which pretty much cover the range of what I want to do. Writing any of those three is a non-trivial effort.

I think there was an unfortunate side effect of early Java releases, in that the startup time for applications pretty much eliminated it as an option for command-line utilities. Plus there was no way to trap key events at a low level, which made some kind of editors difficult to write. This is in contrast with other language competitors from around the same time, like Python or Perl, which were welcoming on the command-line and encouraged people to use them for small-scale tasks. You build up enough small-scale utilities and you can start to put together bigger things.

For GUI apps, it's just a lot of work. I use several Swing apps (outside of NetBeans and IDEA) and it's amazing the little things that very hard-working, professional programmers leave out. Like dialogs without a default button (or where I can't tab between buttons), missing shortcut keys or accelerators, poor use of background threading, long-running processes that can't be cancelled. The list goes on and on. I think it's just a hard problem space to solve or to cover completely, especially when you want portability across OS and that guy with the Mac doesn't want the tab button to do what I want it to do.

Still, there's lots of room for hope. SwingLabs is attracting a lot of bright ideas and hard-nosed discussion. Eventually we'll move beyond reusable libraries (say, for FTP or file compression) and start building a large base of useful visual components with good UI/model sync, so that, say, adding drag and drop, undo or other features will be trivial, or at least not much work. That's probably what I would encourage--build good abstract flexi-models (DataBuffer), using a binding library (JGoodies, or that JSR), build reusable utility components (...), write content/binding/model libraries (Swing-WS?) and wrappers (MySwing) and link them all up.


Joined: 2003-06-09

I can't conjure up a catalog of exactly the kind of apps you're referring to off the top of my head. We do publish pointers interesting apps/applets that happen to cross our radar on Today's applet was a strangely realistic simulation of a drape flapping in the wind. Usually the apps we come across are more mundane :-)

Joined: 2003-06-13

But, see, in truth, a bulk of new Swing coders need simply that -- mundane applications to give them a starting point.

Why do they need mundane examples? Because most tasks today are simply that: mundane.

An example that I have not seen is a "complete" Master/Detail DB CRUD application that uses lookup tables for validation. Something that just about every single Java Swing client programmer in Corporate America has to do today.

An Order Entry program is probably the best example. You have an Order Header, Line Items, Customer lookup on the header, item lookup in the detail, order summary information (price totals, simple taxes), and an order find/browse function (find all orders for customer X).

A demonstration program that does this presents so many aspects of Swing programming that most client programmers need. It also serves as a foundation that beginning programmers can use to create new projects, from a build environment, simple UI design, leveraging layouts, source of icons, DB hookups (JDBC or JPA), etc.

It also handles things like field navigation, tab order, keyboard shortcuts, edit formatters (prices, dates), dialog boxes, etc.

A truly "complete" application.

It can be used to show proper threading practice, Actions wiring, tables with customer renderers, etc. You can even go as far as to add Printing to print the order invoice.

I never said this would be a TRIVIAL client application, but for most developers, this is the kind of application that they want to be "simple", and that they need to write every day.

While paint programs and text editors are all wonderful and such, very few corporate programmers are writing those.

This can be a reference application. The basics are in the Swing tutorial, but if you want to see it in a "real world" "best practice" "performant" version, then you can look at the reference application and see how it's done there. How it all comes together. If someone says "my swing apps are slow", here's one that isn't, with explanations as to why, and code to back it up.

With Java DB now easily available, such a demo can be shipped in a Jar or even a Webstart application along with a nice set of articles walking through the source code, explaining design decisions, and presenting alternatives. For example, a simple Client/Server JDBC version vs a JPA version vs one backed by web services or remote JEE Session beans. Different approaches to handling actions or navigation.

Almost every simple article or app handwaves a lot of either the boiler plate, or best practices, or the "hard stuff" to save space or as an exercise for the reader, so, again, new coders never get a complete view of all the issues they may have to face when writing "simple" applications.

It's been a gazillion years, and I've never seen anything like this anywhere. Lots drawing programs, IDEs, games, etc. But never a "simple" Master/Detail screen.

We have a bunch of Java Blueprints for all sorts of other systems, but nothing for a "simple", circa mid-90's, client/server "fat" client application.

I think the community would find such an application and associated documentation and articles very useful. I know I would.

Joined: 2005-09-19

Well, our application is a business application and of course it is [i]"...Master/Detail DB CRUD application that uses lookup tables for validation..." [/i] besides invoice printing, reporting, faxing etc.

Many other people in corporations might have developed their own libraries to be able to run their application. Without that 'simple' stuff you mentioned, I cannot imagine a business application.

But when it comes to make it a reference application for the community with the document, you have to re-work on it. I mean not impossible, it is a matter of time.

Let's hope this discussion will motivate this.


Joined: 2005-09-19

We have been using a full java-swing-desktop application with a MySQL database server for two years.

From design to development and deployment phases we have dealt with many issues like any other development environment. (Before Java I worked with the others for years)

However -I may not agree with you- whenever I need a code sample for a specific part, I have always found many samples around on the Internet.

I cannot give certain site addresses right away. I use,, javaworld, theServerside, javaalmanac and more. I am sure you know these sites too.

By the way we use Netbeans. Netbeans site also has samples .