: Download: FAQ: Licensing: Support: Contact ME
LwVCL Home
Introduction
Overview
Screen Shots
On-line Demos
Requirements
Further Plans
Docs
Tutorial
How-to (PDF)
API
FAQ
Download
Latest version

Home > J2SE > FAQ





0. Does the J2SE LwVCL support Microsoft JVM?
1. I cannot load an image that is stored in my directory ...
2. Is there any method in the LwTree component to test if the tree node is expanded or collapsed?
3. I already have an AWT application and would like to use the library components ...
4. Can I use the LwVCL components in my visual compositor (JBuilder)?
5. What ways can be used to customize the library components views? ...
6. Does the library provide something like java.awt.Dialog ...
7. Does the library support the mouse scroll-wheel?
8. I would like to have a screen shot of a lightweight panel and its contents ...
9. I use the LwGridLayout layout manager and I found differences in comparison with the java.awt.GridLayout manager ...
10. Is the library multithread safe?
11. Does the library support DBCS?




Does the J2SE LwVCL support Microsoft JVM?

The J2SE LwVCL supports Java 1.1.x or higher, Personal Java, J2ME Personal Profile and Microsoft JVM.

I cannot load an image that is stored in my directory. I use the LwToolkit.getImage method, but it returns null as the result. Is there any solution to solve the problem?

The LwToolkit.getImage method loads images by using one of the following methods depending on the path that has been passed as the method argument:

  • If the path starts with "/", it is used as is. In this case the method looks for the image inside the packages specified in your classpath. For example, if you have a directory named "images" and want to load an image stored there, you should add "." to the classpath and use the following path to fetch the image: "/images/your_fetched_image_name".

  • If the path doesn’t start with the "/", the path is considered as relative to a LwVCL base directory. The base directory is specified by the "lwvcl.base" variable. By default the base directory is "org/zaval/lw/rs" for versions before v4.50 and "org/zaval/lw/theme/base" starting from the v4.50. As in the example described in the previous point you should create the "org/zaval/lw/rs/images" (or "org/zaval/lw/theme/base/images" if the v4.50 or higher is used) directory inside your jar file or your working directory, put all images there and add the package into the classpath. In this case, the "images/your_fetched_image_name" path has to be passed as the LwToolkit.getImage method argument.
Is there any method in the LwTree component to test if the tree node is expanded or collapsed? The provided isOpen method doesn't fit since it considers the node as collapsed if the node or its a parent node is collapsed.

Yes it is possible starting from LwVCL 3.70. Use the following construction to test it:

tree.getItemMetrics(item).isOpen();

I already have an AWT application and would like to use the library components (lightweight panel with different lightweight components) as part of the application. How can I do it?

Usually, to create a lightweight application or applet, you should use the LwFrame or LwApplet components as the starting point. The classes hide all specific activities concerning the library initialization. To add a lightweight panel or component into your AWT application, you should pass through the following steps:

  • Initialize the library. Call the LwToolkit.startVCL method.
  • Create a lightweight desktop. Use the LwToolkit.createDesktop method.
  • The lightweight desktop provides a root container (get it by the getRootLayer method) where you should place all other lightweight components.
  • The lightweight desktop provides a native component (get it by the getNCanvas method) where the desktop lives. The native component is instance of java.awt.Canvas class, so the native can be added to the target AWT application.

The resulting java code is shown below:

LwToolkit.startVCL(null);
LwDesktop desktop = LwToolkit.createDesktop();
yourAWTPanel.add((java.awt.Component)desktop.getNCanvas());

Pay attention to the fact that it is not good to use a simple lightweight component in your Java AWT application because of the resource usage reasons. For example, if you want to use only the LwLabel component, it will cause loading the library resources and so on.

Can I use the LwVCL components in my visual compositor (JBuilder)?

We should say it is impossible to deploy and use the library components inside a Visual Compositor, at least for the following IDEs: JBuilder, Visual Cafe, Visual Age, NetBeans. Most of visual compositors are able to work with java.awt.Component successors only, while lightweight components don't inherit an AWT or Swing component. We are going to provide our own solution that will be available at our WEB site as an LwVCL applet.

What ways can be used to customize the library components views? Is there any method to control application's look and feel like it is done in the Java Swing library?

This is quite a complex question. The current LwVCL versions provide a number of ways to control component's views depending on the component's implementation:

  • View manager. All lightweight components provide a view manager. This is a special class that helps specify views for the component border, background, and face views. Use the getViewMan method to work with the manager.

  • Composite components. A composite component is a container that uses child components as its element views. So to customize the composite component view you can use a set of methods provided by the lightweight container, plus layout managers to customize the child components placing. For example, the LwButton component uses the LwLabel component as its label element. You can set any lightweight component as the label element, and you can use another layout manager to align the label inside the button container area.

  • Component related views customization. A lightweight component can provide its own methods to customize its view elements. Usually, the method has the following signature: setView(int ELEMENT_VIEW_ID, LwView view). For example, the LwTree component provides the possibility to customize node image views.

  • View provider. The view provider is an interface that knows what view should be used for rendering the given data model item. For that purpose, the interface contains the getView method. Typically, this way is used by the components that are bound with a data model and need to render the data model; for examples, see the LwGrid and LwTree components.

As it has been described above, there are many ways to control lightweight component views. The current version of the library doesn't provide a unified way of controlling views. We are thinking about a more universal concept, and most likely it will be re-implemented starting from version 5.00.

Next. The LwVCL properties files and resources (see the "org/zaval/lw/rs" or "org/zaval/lw/theme/base" for v4.50+ directory and subdirectories content) describe many views that are used by the lightweight components as default. To customize the component views, you can follow the methods described below:

  • Modify the properties files according to your needs.

  • Modify or replace components resources that are stored in the base directory. The resources are images, that specify element' views for some LwVCL components. You can find LwTree, LwScroll, LwSpin, etc element' views there.

  • Create your own properties files and resources to load instead of the default set. For that purpose, you should:
    • Make the resources available by means of the classpath.
    • Sets the LwVCL base directory. The base directory is used to look up all resources and properties files that are necessary for the initialization stage. The base directory can be changed by setting "lwvcl.base" environment variable, or with the "lwvcl.base" parameter in case of the applet creation. For example, if you create resources and properties stored in the "my" directory pack, which is in "my.jar", include the package in the classpath and start your application as follows: java –Dlwvcl.base="/my" <className>

  • Use the LwToolkit.loadObjs method to load and re-load LwVCL resources dynamically.

Does the library provide something like java.awt.Dialog or javax.swing.JDialog classes?

You can use the LwWindow or LwBlankDialog components as the modal or none-modal dialogs. You can create your own or use other lightweight components as the dialogs. In both cases, you should get the LwWinLayer layer and add the components to the layer as follows:


LwLayer winLayer = desktop.getLayer(LwWinLayer.ID);
winLayer.add (LwWinLayer.MODAL_WIN, yourModalWin);
winLayer.add (LwWinLayer.MDI_WIN, yourMDIWin);

The method described above is based on the lightweight internal windows layer implementation, so the dialog can be rendered and placed only inside the lightweight desktop area.

The other way is to use the java.awt.Dialog class. Please see the LwAWTDialogUsageSample sample provided by the library package.

Does the library support the mouse scroll-wheel?

Starting from the J2SE LwVCL v4.20 the library provides the special class LwMWheelSupport for the purpose. Pay attention that:

  • The class should be installed manually. See the javadoc to understand how to do it.
  • The class is applied only for J2SE platform.
  • The class is not included in the "lw.jar" or "lwext.jar" package. It is necessary to compile and include the class in the classpath.

I would like to have a screen shot of a lightweight panel and its contents. How can I do it?

You should use LwPaintManager to render the panel using off screen image graphics context as follows:

LwToolkit.getPaintManager().paint(OffscreenImageGraphics, yourPanel, null);

The method renders all component hierarchy of the specified panel (including the panel) using the given graphics context.

I use the LwGridLayout layout manager and I found differences in comparison with the java.awt.GridLayout manager functionality. The lightweight manager doesn't stretch child components over the target container area. What should I do to solve the problem?

By default, the layout manager calculates virtual cell sizes as the maximum preferred sizes among the column members and the row members. It means the layout manager doesn't use the full target component area. The image below illustrates the four button components that have been laid out by the manager:

It is possible to force the layout manager to use full target container area by passing a special bit mask during creating the manager object as it is shown below:

LwGridLayout grid = new LwGridLayout(2, 2, LwToolkit.HORIZONTAL);

See the images below created for the same purpose, but, in this case, the manager uses horizontal, vertical and vertical + horizontal stretching bit masks:



Horizontal

Vertical

Horizontal + Vertical

Is the library multithread safe?

The light-weight components painting is thread safe. But the library is not multithread safe. For example SWING and ATW libraries are not thread safe too, since it is hard to implement and brings to performance issue.

Does the library support DBCS?

Yes. The early versions of the library didn’t support DBCS. We solved the problem in the latest LwVCL versions (starting from LwVCL 3.54).

If you have any questions please send me an e-mail. We will be glad to help you and probably the answer can help somebody else.

: up