|
The SwixNG XML descriptors are in big parts compatible to
SwiXml 1.2. However, there are some small changes you have to apply to make your project work with SwixNG.
Removed features
Some of the features established in
SwiXml were removed from SwixNG. These include:
-
Extended support for MacOS X
The MacOS X specific attributes in your XML descriptor are not handled any more, which means they will get set as ClientProperties of your components in most cases. You will have to remove calls to swingEngine.isMacOSXSupported() and swingEngine.isMacOSX() .
-
Setting default locale in the XML descriptor
The according attribute "locale" will be ignored of appended as a ClientProperty to the component it's defined for. Please set your locale in your main class by calling swingEngine.setLocale(Locale) .
-
Setting pluggable Look & Feel in the XML descriptor.
The according attribute "plaf" will be ignored of appended as a ClientProperty to the component it's defined for. Please set your Look & Feel in your main class by calling UIManager.setLookAndFeel(String) .
-
"initclass" attribute
This got replaced by the "init" attribute. See chapter .
Class names
Aside from the base package name, some of the classes you used from
SwiXml have changed their location and name. This table shows the differences to SwixNG:
SwiXml | SwixNG |
org.swixml.SwingEngine | swixng.swing.SwingEngine |
org.swixml.Localizer | org.swixng.Localizer |
org.swixml.Converter | org.swixng.api.Converter |
org.swixml.ConverterLibrary | org.swixng.api.ConverterLibrary |
org.swixml.Factory | org.swixng.api.TagHandler |
org.swixml.DefaultFactory | org.swixng.api.DefaultTagHandler |
org.swixml.TagLibrary | org.swixng.api.TagLibrary |
SwingEngine class
You should use a reference to ObjectEngine in your code! In SwixNG, the SwingEngine class is a specialized subclass of org.swixng.ObjectEngine .
This table lists the differences between the SwingEngine class in
SwiXml and SwixNG.
SwiXml | SwixNG | notes |
Constructors |
SwingEngine() |
removed
|
SwingEngine(String) |
removed
| |
SwingEngine(ClassLoader,String) |
removed
| |
SwingEngine(Object) |
same
| |
Rendering |
render(URL) | render(String) | Natively supports applets now! |
render(String) | render(String) | |
render(File) |
removed
| |
render(Reader) |
same
| re-enabled since 0.2 |
render(Document) |
removed
| |
--- | render(InputStream) | |
insert(*,Container) | insert(*,Object) | For 1st parameter see render |
setClassLoader(ClassLoader) |
removed
| uses client ClassLoader |
getClassLoader() |
removed
| |
Component handling |
getRootComponent() |
removed
| Use return value of render or insert |
getAppFrame |
removed
| |
setAppFrame(Frame) |
removed
| |
getAllComponentItertor() |
removed
| |
getIdComponentItertor() |
removed
| |
getDescentants(Component) |
removed
| |
getIdMap() |
removed
| |
find(String) |
same
| Now returns Object |
forget(String) |
same
|
cleanup() |
same
| Now returns Object |
Utility accessors |
getLocalizer() | localizer() | |
--- | getAPI() | |
getTagLib() | getAPI().tagLib() | |
getClient() |
same
| |
--- | setClient(Object) | since 0.2 |
Localization |
setResourceBundle(String) | localizer().addResourceBundle(ClassLoader, String) | |
setDefaultLocale(Locale) | Locale.setDefault(Locale) | |
setLocale(Locale) |
same
| |
--- | addLocalizeListener(LocalizeListener) | |
Other |
isMacOSX() |
removed
| |
isMacOSXSupported() |
removed
| |
setMacOSXSupported(boolean) |
removed
| |
setActionListener(Component, ActionListener) |
removed
| |
Localizer class
This table lists the differences between the Localizer class in
SwiXml and SwixNG.
SwiXml | SwixNG | notes |
getString(String) |
same
| |
--- | getString(String,String) | user defined default value |
--- | format(String,Object...) | uses String.format |
setResourceBundle(String) | addResourceBundle(String) | |
getClassLoader() |
removed
| |
isUsable() |
removed
| |
Init parameters
The "initclass" attribute is no longer supported in SwixNG. In exchange, you now have an "init" parameter through which you can pass the name of a public field in your client class. This is the same mechanism you use to bind Actions via the "action" attribute.
Most likely, you will want to pass model classes to, for example, a JTree . Here is an example how to do this in SwixNG:
<frame size="600,400">
<tree init="myTree" />
</frame>
sampletree.sng
public class SampleTree {
public TreeModel myTree;
public SampleTree() throws Exception {
myTree = new DefaultTreeModel(new DefaultMutableTreeNode("root"));
...
}
public static void main(String[] args) throws Exception {
new SampleTree();
}
}
SampleTree.java
You can also use the class swixng.swing.model.ModelHelper to make use of the runtime localization mechanism in SwixNG.
|