Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does Swing need another Layer?

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic