This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Does Swing need another Layer?

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic