aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Does Swing need another Layer? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Does Swing need another Layer?" Watch "Does Swing need another Layer?" New topic
Author

Does Swing need another Layer?

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

A lot of people out there in the community keep addressing the fact that they think Swing needs a higher level that developers use. Similar I supose to how SWT has JFace.

Personally, I think this might be a good idea. So I started playing around with some ideas. Don't slam me on this simple primative example, but see if this is something you think is a good idea to build off of.

When I use a JTextArea there is a lot of initial constructing that needs to be done. For example, I always word and line wrap and I always have a JScrollPane. Here is a typical initialization of a JTextArea:



That's quite a bit of code for getting a typical JTextArea on the screen. So now my custom JTextArea class: (Again, just testing here)



And now to create my Text Area for my GUI from now on:



I included the method to get an instance of the JScrollPane in case it needed to be manipulated or a ViewPort was needed. But which way would you rather add a JTextArea to an application?

I would like to see this kind of a layer on Swing. What do you think?
[ July 08, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Modified the Text class to enable a Context Menu with copy, cut and paste functionality. FYI - I used a Java 1.5 specific method to add the JPopupMenu to the JTextArea so this will only work on 1.5.

And again, this not really the best coding practice or design. I am just doing some testing. So try not to lash me too bad for my code.



And you still just use the single line of code to creat this Text Area and now you have a context menu with copy, cut, and paste funtionality.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

To some extent, isn't this what the JDIC and JDNC projects are about? I certainly see some parallels between them and JFace/SWT.

I think many people have a collection of classes like your "Text" class. I think a standard library of them would be a handy thing, but the problem is that everybody's definition of what belongs in the standard is going to be different.


[Jess in Action][AskingGoodQuestions]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Ernest Friedman-Hill:
To some extent, isn't this what the JDIC and JDNC projects are about? I certainly see some parallels between them and JFace/SWT.

I think many people have a collection of classes like your "Text" class. I think a standard library of them would be a handy thing, but the problem is that everybody's definition of what belongs in the standard is going to be different.


The JDNC API has some additional Swing components like JTreeTable, Application (hmmm, JFace), JDatePicker, etc. So this is close to what I am talking about I suppose.

JDIC is just a way for Swing to have some native ties to the OS. I've looked at it. Most of it seems pointless to me.

I can't tell by the docs if they plan to add more to JDNC in the future or not. I, however, don't like the following statement made on their web site:


JDIC API...usable by developers who may not know Swing


Ummm, what? I guess time will tell. Just seems like extensions like these are a long time coming even with Swing really just being a toddler. M$ just has such a nice Toolkit to use (Windows Forms) it's hard to see Swing winning any desktop realestate on Windows PC's.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does Swing need another Layer?