Easily switch from VB to Swing-based development platform

When Abacus Research AG, a commercial software development company, decided to switch its development platform from Borland's Delphi to Java Swing, it found itself at a crossroads in software development. Our extensive application development team has many years of experience with Delphi. GUI development experience without any Java/Swing experience and we needed to convert a large number of Delphi applications to Swing in a very short period of time. After researching the GUI tools available at the time we felt that we should sponsor a GPL open source Java GUI compiler AbaGUIBuilder Abacus Java GUI compiler is designed to easily switch from VB or Delphi development to Java Swing. This strategy helps Abacus Research achieves the delivery of its Java version applications, shortening development time and allowing developers to focus on business applications instead of the intricacies of the Swing framework. As shown in the figure, AbaGUIBuilder has elements found in many other development environments such as VB and Delphi. It is located in Windows. The upper left corner is the active object tree, and below it is the Swing component selection area. The upper middle part of the window is the development panel, or canvas. Place the Swing component here and instantiate it. The upper right part is the property editor. The lower part is the event panel, which includes two controls. The tab page is the event code editor to add event code for each individual visual object and the message panel to display the status message of AbaGUIBuilder

Figure Why Abacus GUI Compiler Does Us Own GUI tool? Why did we choose to write our own tool? At the beginning we decided that our tool should include the following five requirements? Easy to use. No experience in using layout managers is required. No experience in using Swing is required. No need to output Swing code. To achieve separation of business logic and UI. We evaluated what was available at the time. When developing GUI tools, I found that good IDEs all use hand-written Swing code, which does not meet our first and most critical requirement. The ease of use we define means that any developer can have it in a few minutes regardless of his/her Java Swing experience. Rather than developing a runnable GUI form within a few hours, developers must focus on the business logic rather than the details of the framework. From the beginning, our developers need a WYSIWYG environment so that they can truly perceive when the application is running. The situation when the program was released. The implementation of this function saved developers a lot of time, but none of the tools we evaluated at that time could implement this function. The designed screen was not the same as the output screen, and the scheduling algorithm was poor for us. It's simply a huge step backwards. AbaGUIBuilder implements this feature through preview mode. You can see how it runs during development. Why does Abacus Research require the separation of UI and business logic? Because businesses have to deal with constantly changing rules such as tax and payroll calculations we need the ability to maintain the rules and formulas in a separate package module while maintaining the UI so that the application JAR (UI) is not needed when the formulas change. changes so that only the changed formulas need to be tested. This simplifies the release process. To meet this need we designed the GUI compiler to assemble the application and events into an application JAR. The JAR hides all the GUI Swing code and passes it through a renderer class (AdaRenderer ) No Swing experience is required to execute the application at runtime. In order to ensure that the development tools can achieve true WYSIWYG, we decided to adopt a layout management method similar to XY coordinate positioning in Delphi and VB. In this way, Swing JFrame is a Canvas developers can put Swing components into the XY layout of JFrame. With the XY layout manager, our developers do not need to

It is necessary to understand the complex layout managers that are unfamiliar in Swing so that our application developers can focus on the application UI and its business logic. In fact, AbaGUIBuilder contains most of the Swing visual components from panels to Tab pages also have support for menus, menu items, database-aware components with Java database connections, JFreeChart components, and the ability to import third-party visual class libraries. All of these components can be developed by dragging an empty frame from the component selection area. Your GUI Application Sample Project: Tracking Developer Contact Information The best way to demonstrate AbaGUIBuilder RAD (Rapid Application Development) is to develop a sample application of a multi-text tab panel with a menu bar. First you must go through the Select JFrame in the component selection area and drag it into the application canvas. Place the JFrame object into the empty form panel and then place all visual components on the JFrame. Note that when you start a new project, you must first place the JFrame. Make it your object canvas as shown in the picture

Picture application JFrame as canvas Click on the thumbnail to see the full picture Next add a tab grid and two tab pages in Select JTabbedPane in the container area of ??the component selection area and drag it into the JFrame. After the JTabbedPane is placed, right-click and select Add JATabPage in the pop-up menu to add two tab pages to the panel as shown in the figure.

 

Image-adding tab page: Right-click the tab page and select Add JATabPage, then select TabTitle in the property bar to set the title for each tab page

Diagrams can be placed into empty tab pages of Swing components. Now you have two empty tab pages. You can select any Swing component from the component selection area and place it in it. In our example The developer tab page contains two screens with a series of JLabel and JTextField objects. You can quickly develop a graph-like application. As a visual application developer, you can experience the power of using the Abacus GUI compiler. Gives you the convenience of developing complex GUI applications

The perspective mode included in the compiler is a very useful feature for short-term development of applications because it can Preview the application at runtime. You can enter perspective mode by selecting the Run option on the toolbar or pressing the F key.

What you see is what you get: Check the visual effects during development. Save your work. Press Ctrl S or select the Save option. Name the project devteam. Save it to the examples directory. After you save the project, open the examples directory of AbaGUIBuilder. Open the file devteam proj. A proj file is an XML file in which the application is defined. All classes in Objects Object properties and even code This is an expression platform for your visual projects Adding event handlers Adding event handlers for each object is a straightforward process. All you have to do is click on the object and select it from the event list. You want to interrupt the generated event and fill in the appropriate Java code for the event. Once again, the design of AbaGUIBuilder conforms to the patterns of Delphi and VB. Our goal is to hide the implementation of the UI such as event listeners from application developers. For example, as shown in the figure. To implement a confirmation dialog box that pops up when the Exit button is pressed, first select the actionPerformed event of the Exit button and then fill in the following Java code

 

The picture shows the visual component adding an event handler. Remember the event Handles are not available in the IDE perspective mode and are only activated at runtime so you have to compile and run the application to check the results. Visually adding a menu and menu items is another powerful and time-saving feature. All you have to do is Select from components

Select JMenuBar and place it anywhere in the frame. JMenuBar is usually placed at the top and the XY coordinates are irrelevant. Then right-click on JMenuBar. A pop-up box will pop up as shown in the figure. Add JMenu JMenuItem(s) and event handlers to the menu

< /p>

Figure visualization adds menus and menu items and then copies the actionPerformed event code of the Exit button to the Exit menu item so that the same confirmation dialog box pops up regardless of whether the Exit button or the Exit menu item is selected. Finally, click Save in the toolbar. (With?Compile) Now that you have completed your first AbaGUIBuilder application, where is the code? We often hear this question: Where does the code go? AbaGUIBuilder does not create Java code, but the Java code generated internally by the compiler is not seen and used. In fact, the GUI compiler compiles the internal code into the application's jar file by running a separate wrapper (renderer). You can detect the Java code generated by AbaGUIBuilder in the \bin\output directory, but remember these codes and use them externally. It is only used as an auxiliary tool to generate the project file (proj) in case there is a problem with the code generated by the compiler. After GUI compiler generates two files your application jar file and decl file then when you write wrapper file decl file will be helpful it contains all object definitions and a common entry function getReferences() and it will be used in UI form All visual elements are written as private variables. We can use these private variables in the program section of the decl file to achieve the separation of business logic and UI. During the development process, we recommend that you use the runproz script in the example folder to run your application jar file. This script file sets the classpath and populates all required JARs. Use the sample Java wrapper to run the application JAR as shown. When you run the devteam application the command is runproz \abaguibuilder \samples\devteam jar

< /p>

Diagram of deployment application It is important to understand the mechanism of runproz. Although it is very simple, let us pay attention to the following line %JAVA_HOME%\bin\java exe exec % exec is the default loading mechanism parameter provided by the sample wrapper AbaRenderer % refers to AbaGUIBuilder The name of the application JAR. When the path and name of the JAR are passed to exec java it will load and run the specified application JAR. This is the mechanism by which the application JAR is run. Write your own wrapper. The AbaRenderer wrapper is an AbaRenderer object that loads the application. The Java program wrapper for the program jar is a simple program that requires only a few lines of code public class?exec{ public static AbaRenderer?m_AbaRenderer;? // Assignments for this user interface public static void main(String[] args){String docname = new String(args[ ]); try?{?System out println( Loading + docname);m_AbaRenderer = new AbaRenderer(docname true null);?boolean bTestLoad = m_AbaRenderer load();?if(bTestLoad)?m_AbaRenderer renderInterface(); }?catch(Exception e)?{e p

rintStackTrace();}}} When deploying an application you can choose to use runproz and the sample wrapper to publish it, or you can use your own wrapper and classpath when you need to add other features to your wrapper. It is recommended that you write your own wrapper, such as using a third-party library's listener to manually initialize the object, add code to the combo box, or finally separate the UI from the business logic, etc. Separate the business logic from the UI in order to separate the application's UI and To separate the business logic you have to write your own wrapper. A simple example of separation is to manually initialize the visual components of the application through the wrapper outside the development tool and project. When you call it again the GUI compiler generates a declaration file. This file has An access method can initialize a series of private variables. These private variables are references to visual objects on the form. The getReferences() method allows developers to access and manipulate any visual component on the form. The following exec program is at the first tab position. Initializing a combo box demonstrates the separation of UI and business logic in a simple application

public class?exec { public static AbaRenderer?m_AbaRenderer;// Declarations of variables for this user interface... private JComboBox JStComboBox ;? // Assignments for this user interfacepublic void getReferences(){? … //Loads the visual object JComboBox to private data JComboBox JStComboBox= (JComboBox)m_AbaRenderer getObject( JComboBox );… }? // Assignments for this user interfacepublic static void main(String[] args){String docname = new String(args[ ]);? try{System out println( Loading + docname); m_AbaRenderer = new AbaRenderer(docname true null); boolean bTestLoad = m_AbaRenderer load();if (bTestLoad) { m_AbaRenderer renderInterface(); getReferences();?// Sample access to objectsJStComboBox addItem( FL );JStComboBox addItem( CA );JStComboBox addItem( WA );JStComboBox addItem( MD );JStComboBox addItem( PA ); } }catch(Exception e){? e printStackTrace();}}} lishixinzhi/Article/program/Java/hx/201311/25630