QSwing vs. Swing

Action Listener Example

QSwing Swing

Code

package yu.ac.bg.etf.javaqx.demo.qsvs.qswing;

import yu.ac.bg.etf.javaqx.qswing.JQButton;
import yu.ac.bg.etf.javaqx.qswing.JQFrame;
import yu.ac.bg.etf.javaqx.qswing.QSwing;
import yu.ac.bg.etf.javaqx.qswing.events.ActionEvent;
import yu.ac.bg.etf.javaqx.qswing.events.ActionListener;

/**
 * Action Listener Example.
 */
public class ActionListenerExample {

  public static void main(String[] args) {
    JQFrame frame = new JQFrame("Hello World");
    frame.setDefaultCloseOperation(JQFrame.EXIT_ON_CLOSE);
    JQButton button = new JQButton("Close");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }
    });
    frame.add(button); // <-- SD
    frame.pack();
    frame.setVisible(true);
    QSwing.startEventLoop()// <-- SD-
  }

}
package yu.ac.bg.etf.javaqx.demo.qsvs.swing;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

/**
 * Action Listener Example.
 */
public class ActionListenerExample {

  public static void main(String[] args) {
    JFrame frame = new JFrame("Hello World");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }
    });
    frame.getContentPane().add(button);
    frame.pack();
    frame.setVisible(true);
  }

}

Screenshots

QSwing Compact
package yu.ac.bg.etf.javaqx.demo.qsvs.qswing;

import yu.ac.bg.etf.javaqx.qswing.JQButton;
import yu.ac.bg.etf.javaqx.qswing.events.ActionEvent;
import yu.ac.bg.etf.javaqx.qswing.events.ActionListener;
import yu.ac.bg.etf.javaqx.qswingx.JQMainFrame;

/**
 * Action Listener Example.
 */
public class JQActionListenerExample {

  public static void main(String[] args) {
    JQMainFrame mainWindow = new JQMainFrame("Hello World");
    JQButton button = new JQButton("Close");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }
    });
    mainWindow.add(button)// <-- SD
    mainWindow.pack();
    mainWindow.show();
  }

}