Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Chat

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 
Office Hours Transcripts Index

Office Hours
Fundamentals of JavaTM Foundation Classes (JFC) Project Swing, Part II
April 29, 1999

Moderator (MDR): John Zukowski

MDR-jaz: Welcome folks to this week's Office Hours for JFC Project Swing, Part II. My name is John Zukowski with the MageLang Institute and I'll be here for the next hour to answer questions for you about JavaTM Foundation Classes (JFC) Project Swing (Project Swing) and the online tutorial.

If you are not familiar with the tutorial, it is available at the JavaTM Developer ConnectionSM (JDC) at:

MDR-jaz: Our first question of the week comes from ryanxpx.

ryanxpx: What are the features of Project Swing that will become most important in the future (Actions, Collections, etc)?

MDR-jaz: Welcome ryan.

How long of a future are you looking for?

ryanxpx: I'm seeing a lot of value in Actions, and a thrust towards Collections. I just want to make sure that I'm putting my efforts towards features that won't soon be deprecated.

MDR-jaz: Currently, the Project Swing components do not do anything special with the JavaTM 2 Collections architecture, as it is Java 2 only.

Since Project Swing is meant for both the Java 2 platform, v. 1.2 and the Java Development Kit (JDKTM) 1.1, they can't really be used.

I like the Action/AbstractAction/TextAction framework and its flexibility. With enough front end design work done, using the Action capabilities should help in the maintenance phase of the project.

ryanxpx: Should we assemble all actions into say, an ActionManager, and then access them all through him? Any opinions?

MDR-jaz: Depends on the Action. There already is an equivalent with text components and TextAction. I'm not sure if adding an ActionManager adds much.

Let's move on to the next questions here. We can talk about this more after office hours are over.

mymymy: Hi John, I have your Abstract Window Toolkit (AWT) reference and it has been very useful to me. Please be advised that when I run the MyButton, look and feel example program from the Project Swing, Part II course, it will not allow me to swap the look and feel. My question is: Would it be possible to force a certain look and feel for an individual component to stay constant? I'll give you an example: Say I want the Windows look and feel for the JSplitPane to be used, even if the look and feel is set to something other than Windows, via UIManager.setLookandFeel().

MDR-jaz: Welcome, my. On what platform/version does MyButton not work for you?

mymymy: Windows NT, JDKTM version 1.21 platform.

MDR-jaz: Where did you place the new look and feel classes? They need to be in a trusted path, not CLASSPATH.

mymymy: That's probably the problem. I didn't put them in the trusted classpath.

MDR-jaz: Place the "my" directory in \jdk1.2.1\jre\classes.

mymymy: Okay thank you. I will do that.

MDR-jaz: Or, package the classes up in a jar and place in \jdk1.2.1\jre\lib\ext.

As an FYI re earlier collections discussion: they are usable in JDK 1.1, just they are different classes and they are available from http://java.sun.com/beans/infobus/index.html#COLLECTIONS.

I'm checking the instructions on the use of the MyButton example to make sure it says to use the right place.

This has changed through the different beta cycles. Though, now that it is out of beta, I thought it was trusted only.

If the tutorial doesn't say so already, will make sure it says to use "trusted classpath."

Let's move on to the next question, unless you have something else to add.

ryanxpx: Project Swing in Applets is best served in a controlled environment, such as an Intranet, or where you have control over the client browser installation. Do you see AOL 5.0 being a Netscape NavigatorTM-based applet with the plug-in?

MDR-jaz: Welcome back, ryan.

I agree with your first statement, but am not sure what you mean by the second. Can you please clarify?

ryanxpx: AOL/Sun/Netscape deal. It would make a lot of sense, for all parties, if AOL 5.0 was a Java 2 applet, and they shipped Netscape with the plug-in on the AOL CD.

MDR-jaz: Not sure where AOL is going with their next release. Just waiting for them to announce a 2-1 stock split.

Given the acquisition of Netscape, it would seem they might shift to that as browser. However, then they lose their positioning on the Windows desktop.

mymymy: I'm having a little difficulty with using this chat program, however, I was wondering if you could get to my previous question: Would it be possible to force a certain look and feel for an individual component to stay constant? I'll give you an example: Say I want the Windows look and feel for the JSplitPane to be used, even if the look and feel is set to something other than Windows, via UIManager.setLookandFeel().

MDR-jaz: Whenever you swap look and feels, all component UIs swap.

If you want to force one UI to stay the same...such as using a windows look UI for split pane always, and metal for the rest, your best bet is to create a new LNF and create your own component mapping.

Wait, cancel that.

To make the WindowsSplitPaneUI the UI under something like metal, just do a

    UIManager.put("SplitPaneUI", ("classname");
where classname would be the String com.sun.java.swing.plaf.windows.WindowsSplitPaneUI

mymymy: Okay, great. I will try that. Thanks a lot for your help.

MDR-jaz: I'm not sure, but I think this would bypass the Windows look and feel check and would even work under the SolarisTM operating system, Linux, etc.

You would do the put after changing the look and feel to replace what the LNF puts there.

mymymy: I see.

MDR-jaz: It's amazing how much you can change with just a few UIManager.put calls, if you know the keys.

Let's move on to the next question.

ryanxpx: What is the proper way to refer to external files and resources (like icons) in general? Should we use <currentclassname>.class.getResource(), or should we retrieve the package name ourselves and build up the pathname, or what?

MDR-jaz: Welcome back again ryan.

It seems that doing something like new ImageIcon("filename") will not work if filename is in a jar file.

I do something like

    InputStream is = relativeClass.getResourceAsStream(filename);
and convert the file over myself.

ryanxpx: Sounds good. Thanks.

ryanxpx: Name some good Project Swing resources (particularly any list groups.)

MDR-jaz: For Java resources, my favorite is http://java.miningco.com, but then again, I maintain it.

http://codeguru.developer.com/java/ has some good code examples.

There are two Project Swing-related mailing lists.

http://java.sun.com/docs/books/
tutorial/uiswing/index.html
is Sun's online Project Swing tutorial. It's free, and a different tutorial than JDC tutorial. Lately, I've grown to like the Java Power Reference from David Flanagan/O'Reilly.

ryanxpx: I found an obscure but helpful one: http://www.eos.dk/archive/swing/

MDR-jaz: Yes, that's one of the mailing lists.

ryanxpx: Do you know the others off the top of your head?

MDR-jaz: http://www.confluent.fr/
javadoc/JavadocE.htm
has the JavaDocs in WinHelp format.

ryanxpx: Cool. Thanks.

MDR-jaz: The Swing Connection is another resource http://www.theSwingConnection.com.

With the question queue empty, I thought I would ask a question: Does anyone know how to get Java 2 to use foreign fonts? I'm trying to display some Japanese characters. I have the appropriate font installed, but what works in Java 1.1 isn't working for me in Java 2.

(For an answer to this question, please see the addendum at the end of the transcript.)

ryanxpx: You've got a lot of good answers. It's a long time between Office Hours (normally I'd like that..) Do you frequent a newsgroup, or is there a forum on miningco?

MDR-jaz: Thanks ryan. I monitor the Project Swing mailing lists, I gave up on advanced-java as the signal-to-noise ratio was too low. There is also a bulletin board area at my miningco site.

ryanxpx: Accessing local OS fonts: I've found that you have to "load" the fonts first before you access them, by calling GraphicsEnvironment.getAllFonts().

MDR-jaz: If you think there should be more office hours, or a return of the former code clinics, let the folks at Sun know.

ryanxpx: Cool. Thanks.

MDR-jaz: If I use GraphicsEnvironment, then the program won't run under both 1.1 and 1.2.

Boy is getAllFonts slow.

ryanxpx: Sorry. Can't help with 1.1 fonts. I'm done. Thanks.

MDR-jaz: Didn't work, oh well. Got 1.1 going.

Well, it seems we're out of questions and it is the top of the hour.

ryanxpx: Can I send you a working snippet at miningco or MageLang?

MDR-jaz: Of what, ryan?

ryanxpx: OS fonts under Java 2.

MDR-jaz: I have OS fonts going, but not Unicode characters.

ryanxpx: Ah. I see. OK. thanks for your time Jaz. Come back soon.

MDR-jaz: Trying to display something like "\u4E00" (one). Working in JDK 1.1....

Well, thanks for everyone for coming. Hopefully I answered your questions. Good luck with tutorial and watch for new tutorial some time in May.

Last moderator (me) signing off. The forum is now unmoderated.

Thanks for coming folks. Watch for news of more office hours with next tutorial.


Addendum

For the solution for my question.....

It turns out that the font.properties.ja file of Java 2, version 1.2 refers to a different Japanese font file than the Java 1.1 version of the file. After getting the MSGothic font from http://ftp.monash.edu.au/pub/nihongo/ie3lpkja.exe, installing, and changing the font.properties file to look for ttf files, instead of ttc files, it worked.

If someone can point out where to get the TTC files to reduce initialization time... I would appreciate that as startup time is slow.

  
filename.\uff2d\uff33_\u660e\u671d=MSGOTHIC.TTF
filename.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=msmincho.ttf
  

coffeecup


Reader Feedback

Tell us what you think of this transcript.

Duke

Very worth reading Worth reading Not worth reading

If you have other comments or ideas for future articles, please type them here:


Print Button
[ This page was updated: 21-Sep-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary | Feedback | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.