1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d.test;
21
22 import java.awt.*;
23 import java.awt.event.*;
24 import javax.swing.*;
25 import camera3d.gui.*;
26 import camera3d.*;
27
28 /***
29 *
30 * @author Fábio Roberto de Miranda
31 */
32
33 class DigControlTestFrame extends JFrame implements DoubleValueChangeListener {
34 private JPanel contentPane;
35 private DoubleDigitalControl doubleDigitalControl1 = new DoubleDigitalControl();
36 private DoubleDigitalControl doubleDigitalControl2 = new DoubleDigitalControl();
37 private DoubleDigitalControl doubleDigitalControl3 = new DoubleDigitalControl();
38 private JButton setTestBtn = new JButton();
39 private JTextField jTextField1 = new JTextField();
40
41 /***Construct the frame*/
42 public DigControlTestFrame() {
43 enableEvents(AWTEvent.WINDOW_EVENT_MASK);
44 try {
45 jbInit();
46 }
47 catch(Exception e) {
48 e.printStackTrace();
49 }
50 }
51 /***Component initialization*/
52 private void jbInit() throws Exception {
53 //setIconImage(Toolkit.getDefaultToolkit().createImage(DigControlTestFrame.class.getResource("[Your Icon]")));
54 contentPane = (JPanel) this.getContentPane();
55 contentPane.setLayout(null);
56 this.setSize(new Dimension(400, 300));
57 this.setTitle("Testing digital control");
58 doubleDigitalControl1.setBounds(new Rectangle(16, 19, 68, 35));
59 doubleDigitalControl2.setBounds(new Rectangle(159, 53, 68, 35));
60 doubleDigitalControl3.setBounds(new Rectangle(70, 144, 68, 35));
61 setTestBtn.setText("set value");
62 setTestBtn.setBounds(new Rectangle(184, 236, 95, 29));
63 setTestBtn.addActionListener(new java.awt.event.ActionListener() {
64 public void actionPerformed(ActionEvent e) {
65 setTestBtn_actionPerformed(e);
66 }
67 });
68 jTextField1.setText("55.0");
69 jTextField1.setBounds(new Rectangle(283, 236, 70, 30));
70 contentPane.add(doubleDigitalControl1, null);
71 contentPane.add(doubleDigitalControl2, null);
72 contentPane.add(doubleDigitalControl3, null);
73 contentPane.add(setTestBtn, null);
74 contentPane.add(jTextField1, null);
75 doubleDigitalControl1.addValueChangeListener(this);
76 doubleDigitalControl2.addValueChangeListener(this);
77 doubleDigitalControl3.addValueChangeListener(this);
78 }
79 /***Overridden so we can exit when window is closed*/
80 protected void processWindowEvent(WindowEvent e) {
81 super.processWindowEvent(e);
82 if (e.getID() == WindowEvent.WINDOW_CLOSING) {
83 System.exit(0);
84 }
85 }
86
87 public void valueChanged(DoubleChangeEvent ev){
88 DoubleControl dc = (DoubleControl)ev.getSource();
89 double value = dc.getValue();
90 System.out.println("Somebody had its value altered to: "+value);
91 }
92
93 void setTestBtn_actionPerformed(ActionEvent e) {
94 doubleDigitalControl1.setValue(java.lang.Double.parseDouble(jTextField1.getText()));
95 }
96 }
This page was automatically generated by Maven