Java Qt Extensions

Examples

Example8 - Model

This example shows the usage of the Model-View-Controller (MVC) design pattern.

QSwing uses a modified MVC architecture similar to Swing's UI Delegates. All three components in the example share the same data model which means that data change in one component will automatically reflect on the other two.

Code

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

import yu.ac.bg.etf.javaqx.qswing.BoundedRangeModel;
import yu.ac.bg.etf.javaqx.qswing.DefaultBoundedRangeModel;
import yu.ac.bg.etf.javaqx.qswing.JQContainer;
import yu.ac.bg.etf.javaqx.qswing.JQProgressBar;
import yu.ac.bg.etf.javaqx.qswing.JQScrollBar;
import yu.ac.bg.etf.javaqx.qswing.JQSlider;
import yu.ac.bg.etf.javaqx.qswing.QSwing;

/**
 * Model Example.
 */
public class Example8Model extends JQContainer {

  public Example8Model() {
    super(null);
    setName("Bounded Range Model");
    setFixedSize(296100);
    BoundedRangeModel model = new DefaultBoundedRangeModel(5000100);
    JQSlider slider = new JQSlider(model);
    slider.setBounds(101027420);
    add(slider);
    JQProgressBar progressBar = new JQProgressBar(model);
    progressBar.setBounds(104027420);
    add(progressBar);
    JQScrollBar scrollBar = new JQScrollBar(model);
    scrollBar.setOrientation(JQScrollBar.HORIZONTAL);
    scrollBar.setBounds(107127418);
    add(scrollBar);
  }

  public static void main(String[] args) {
    Example8Model modelExample = new Example8Model();
    modelExample.setVisible(true);
    QSwing.startEventLoop(true);
  }

}

Screenshots

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