Overview
JSwing that we design is not a Java Swing, it is a Java swing-based library for simplifying the development of graphical user interface (GUI) applications. It is suitable for desktop application systems built on Java swing.
JSwing application consists of a form that handles data rendering and an application for user interaction. It provides a clear separation of forms and applications, and this architecture facilitates task synchronization between Forms and Applications, thereby enhancing development capabilities.
Features of JSwing
- Clear structures and easy to learn.
- The form designer and application developer can be synchronized.
- Built-in event listeners for all JComponents.
- The screen scrolls automatically by the cursor position.
Audience
This quick start guide is designed for JSwing software developers who want to learn JSwing graphical user interface (GUI) Programming in simple and easy steps. This guide provides a basic understanding of JSwing GUI Programming concepts that help you build desktop applications using JSwing.
Prerequisite
Before using JSwing libraries in depth, you must have a basic knowledge of Java swing. Such as GUI components, events, event handlers, etc. Choosing a Form and Code designer is very important to study JSwing, and We recommend that use Apache NetBeans. All our guides are designed in NetBeans, and you can download the latest release of the NetBeans from https://netbeans.apache.org/download/index.html.
The following are steps to create a JSwing application in NetBeans.
Before beginning
Create a JSwing project in NetBeans
Start Apache NetBeans > File(Ctrl+Shift+N) > Java with Ant > Java Application, then click Next.
Type JSwingApplication into Project Name, and then click Finish.
Add JSwing Library
Select JSwing projects and Right-click > Properties > Libraries > add jswing.jar to Classpath.
Make two Java packages names app and form
Select SourcePackages of your JSwing projects and right-click > New > Java Package.
Finally, the project tree view is shown as the following
Step 1: Build a Simple JSwing Form
Build a JSwing Form names HelloJSwing
- Select and Right-click form > New > JFrame Form > enter HelloJSwing to Class Name > Finish.
- Drag a JButton onto the form.
- Change properties of text, actionCommand, name from default to Hello.
- Save and compile.
Step 2: Build a JSwing App
Build a JSwing App names HelloJSwing
package app;
import jswing.application.*;
public final class HelloJSwing extends App {
public static void main(String args[]) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Form.open("form.HelloJSwing","HelloJSwing");
UserInterface.initialize("app.HelloJSwing",Form.getCurrentForm());
}
});
}
@Override
public void actionPerformed(java.awt.event.ActionEvent e){
//TODO add your handling code here with actionCommand
String action = e.getActionCommand();
switch(action){
case "Hello":
javax.swing.JOptionPane.showMessageDialog(null,
"Hello JSwing",
"Dialog",
javax.swing.JOptionPane.INFORMATION_MESSAGE);
break;
}
}
}
Step 3. Run the application
Click Run > Run File or Shift+F6, you will get the following result.
Next, read more tutorials about on JSwing
You’ve already seen how simple JSwing can be. We have some guides available, so why not keep on learning and try these additional guides? In the next topics, we will be going to take you to create simple JSwing applications, Or you can also download JSwing and getting start now.