Moderator (MDR): MDR-Andrea
Guest Speaker (SPK): SPK-jaz
MDR-Andrea: Hello and welcome to Java Live. Today's guest is John Zukowski of the MageLang Institute. He recieved a B.S. in computer science and mathematics from Notheastern University, Boston, and an M.S. in computer science from Johns Hopkins University, Baltimore, MD. He is author of Java AWT Reference from O'Reilly & Associates and Borland's JBuilder: no experience required. from Sybex. John has extensive experience with Java, including being one of the first non-Sun instructors of the language. He currently works for MageLang, hosts JDC Code Clinics, and maintains a web page "Focus on Java" at http://java.minigco.com. Please feel free to start sending in your questions. And welcome, John.
SPK-jaz: Thanks for the welcome.
calvin: If Swing is written on top of JDKTM 1.1, why doesn't it work in the 1.1 browsers?
SPK-jaz: Our first question..... Oh goodie... ;-) Swing requires Java 1.1.2. Prior to today's release of Microsoft's Internet Explorer 4.0, there was no released browser that was anywhere near to fully supporting Java 1.1. Netscape Communicator 4.0 has a patch for Java 1.1, but it is only in developer/beta release. HotJavaTM from Sun does support JDK 1.1. As far as using Swing in browsers, Swing requires access to the system-event queue. This is a restricted capability. Thus, untrusted/unsigned applets cannot access it, thus Swing will not work.
irinaR: Hi, do we have an agenda today?
A question: I was told there is no Java spec regarding the z-order of overlapping components, and that every VM behaves differently. So what do we do? Not overlap at all?
SPK-jaz: Regarding the agenda, I think we listed Swing, AWT, and JavaBeansTM as the topics. These are the topics of my recent books. Since I also do the Code Clinics on Thursday, I wanted to try to reserve the more technical questions for then.
Regarding the overlapping components/z-order. To the best of my knowlege, it is undefined. However, there is nothing that stops you today from creating a LayoutManager that supports it. Swing actually adds a LayeredPane that permits layering. If you try out the SwingSet examples, there is usage of it with the JInternalFrame. Prior to Swing, the best thing to do was avoid overlap.
irinaR: Does the LayeredPane behave similar to the null layout?
SPK-jaz: LayeredPane is not a layout manager, but rather a component. One of the pieces of information it contains (property) is a layer that it should be drawn on. If you place a JLayeredPane in a container that uses BorderLayout, there will be no layering, since there is no overlap.
lavinio: A question about JBuilder: JBuilder comes with support for JBCL, JClass, and (of course) AWT. They all provide support for GUI development, and the first two also for GUI-to-database wiring. What are their pros and cons, and in what circumstances would you recommend using one instead of the others?
SPK-jaz: Don't forget about Swing too. They are usable in JBuilder.... I like the JBCL components. They have a rich Model-View-Controller architecture, so that once you understand them, they are great to work with. This is similar to Swing, and its architecture. The database hooks are nice. I've avoided learning JClass since I didn't see the advantage of using it over JBCL or AWT/Swing. Using anything outside of the Java core classes adds to the package that needs to be delivered with the Java program. For applets, I tend to stick to the lowest common denominator, AWT 1.0. For applications, I would go with JBCL or Swing, once available. For an intranet applet, you can use AWT 1.1, but outside of an intranet, you have too much potential to lose a customer/client who doesn't have the latest browser.
By the way, regarding the layering/z-order, Java 1.0 was undefined. Java 1.1 seems to be defined, which is how the Swing layering works with JLayeredPane. It basically just sets the order added to the container.
lavinio: I didn't forget Swing :-) I'm really looking forward to it.
But, being at 0.41, I'm afraid it's still not solid enough, at least for the kind of Intranet DB applications we need to write, while the need to add the JBCL packages to the JRE is not a concern in our present scenario.
SPK-jaz: The next release of Swing is supposed to be mature enough to start application development, but not delivery. The API changes from .1 to .2 to .3 to .4.1 have been fun for trying to keep things up to date. Just a few comments about JBuilder: JBuilder comes with Java 1.1.2+. The 1.1.2 version with some Borland-specific patches. So, it does support Swing. Like the BeanBox, JBuilder allows you to have a palette of Beans, drop them into your program and connect them all up and set properties. The nice thing that JBuilder does (and most of the Java 1.1 IDEs), that the BeanBox doesn't do, is allow you to edit the code, in addition to just connecting things. JBuilder doesn't support making .exes. However, it has a nice dependency-packaging tool. So, if you want to deliver an application, you just start up a wizard, pick the application's class file, and say "package into .jar/.zip," compressed or uncompressed. JBuilder tries to only create 100% Pure JavaTM programs, so things like creating platform-specific .exe files are not currently available. One other nice thing it does, happens to be a question....
calvin: Can an applet be a Bean?
SPK-jaz: JBuilder has a nice wizard that automatically wraps an applet into a Bean. You can do this yourself manually, but the automation of it is really nice. If an applet has, let's say, 10 HTML parameters that can be passed to it, each parameter is made into a property of the Bean. Then you just use the applet's wrapper class as a Bean. Without the wrapper class, an applet can function as a Bean. However, if the developer didn't create the appropriate methods for the parameters, you can't set the parameters. Let's move off JBuilder for a moment for the next question....
JWBito: It would be helpful to me if you'd describe a technique for periodically updating the contents of a component, say to track changed values in a database. From using other window toolkits, I am inclined to set a timer and repaint the component at intervals. The update method would then be responsible for retrieving fresh data. Is there a different preferred approach for Java 1.1? How about Swing? Does either toolkit incorporate a timer event (like MS-Windows)?
SPK-jaz: Swing adds a Timer class that more uniformly supports the capabilities you desire. Basically, you register an ActionListener that should be notified every so many milliseconds (or is it nanoseconds?). Then, when you are notified, you can do whatever you want. You can create the capabilities yourself in Java 1.1, or with a little work in 1.0. However, without the class, twenty different people would probably do it 19 different ways.
sorbox: Can you ICMP (Internet Control Message Protocol) with Java or make resident programs (like the clock, the ones that are on the bottom right of the window bar)?
SPK-jaz: With a little work, you can create Java programs that are windows-specific and appear on the bottom right for Windows. I use one that is currently in beta called Ding! Look at www.activerse.com for the software. I think I remember seeing a package to use that helped you to create programs like that (on the windows status bar), but I don't recall where I saw it. If you search the Usenet archives at DejaNews, you should be able to locate mention of it. Either that or post a message to the advanced-Java or MageLang email lists. See http://java.miningco.com/msub7.htm for signup instructions.
Andrea: In case you are interested in having John take a look at your code, or answer technical questions, join the Code Clinic this Thursday (and every Thursday from 10 a.m.-12 p.m.(Pacific Daylight Time). Please be aware that the time has changed, so be sure to check the schedule (linked from the Discussion Fourms page on the JDC) and inform any other developers you may know.
sorbox: Is there a preview of JBuilder?
SPK-jaz: Unfortunately, Borland does not seem to offer a functioning preview. They do have a 30-day money-back guarantee. So, if you buy it and don't like it, you can get your money back. There is an online tour of the program, but it isn't the same thing.
paradigm: Bean questions, eh? What's your favorite IDE for Beans? Given your recent authoring experience, is that a loaded question? :-)
SPK-jaz: I've tried VisualAge for Java and JBuilder of the Java 1.1 tools. I haven't played with SuperMojo, or the latest Visual Cafe. There are certain features of VisualAge that I like, other features of JBuilder that I like, and some things in BeanBox that neither does. With VisualAge, it uses Java 1.1.1, not 1.1.2 or higher. Because of that, I can't use it for the Swing work I do. It also doesn't support inner classes, and is based on a repository model that has you importing and exporting things alot. JBuilder doesn't support Bean customizers, and is a little less sophisticated in connected Beans. However, it is 1.1.2-based, so it supports Swing, and does understand inner classestwo things that are important to me today. With the Sept 97 edition of BeanBox, it now has a delivery mechanism for applets, so is pretty cool for just simple little applets, where you don't have to touch the code.
dluckevich: Picture a spreadsheet. Each column is defined using a GridLayout and each column is resizable by the user who supplies parameters in the HTML that specify the font style and size. The column is composed of text fields topped with a choice box and button. Java scales the width of the column to be big enough for the biggest element in the grid. My question is: Why is a certain width of the text fields big enough for PC displays but too small on a Unix display? In other words, a TextField in Unix, when defined as 10, doesn't hold 10 characters. Thanks.
SPK-jaz: The column parameter of TextField is not meant to say that it can fit that many characters. It depends on the contents of the TextField. It uses a mean character width for sizing purposes.
If you have to make sure a TextField is wide enough, you need to use the FontMetrics for the font used. A 10-point font on Motif is a different point size then a 10-point font under Windows. In order for the program to size properly, it is necessary to program defensively with Java. The 100% Pure Java Cookbook has lots of points and tips that help in creating programs that are not just Write Once, Run AnywhereTM, but write once, run the same everywhere. Do come by Thursday for the Code Clinic.
Andrea: Thanks to everyone for joining. Tune in next week for a talk with Ofer Ben-Shachar from NetDynamics. Check the Discussion Fourms page for complete details.
SPK-jaz: Thanks for coming by....