Java Qt Extensions

Examples

Example2 - Action Listener

A simple example of responding to a user-initiated action using an anonymous inner ActionListener.

Like Swing, QSwing component set uses the delegation-based event-handling mechanism and follows the JavaBeans specification.

Code

package yu.ac.bg.etf.javaqx.examples;

import yu.ac.bg.etf.javaqx.qswing.JQButton;
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;

/**
 * ActionListener Example.
 */
public class Example2ActionListener {

  public static void main(String[] args) {
    JQButton button = new JQButton("Close");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        QSwing.stopEventLoop();
      }
    });
    button.setName("Hello World");
    button.setSize(15050);
    button.setVisible(true);
    QSwing.startEventLoop(true);
  }

}

Screenshots

ActionListener on
Windows Vista
ActionListener on
Windows XP
ActionListener on
Windows 98
ActionListener on
SUSE Linux
ActionListener on
Ubuntu Linux