/Users/lyon/j4p/src/bookExamples/ch19Events/observables/TripletPanel.java

1    package bookExamples.ch19Events.observables; 
2     
3    import gui.run.RunSlider; 
4     
5    import javax.swing.*; 
6    import java.awt.*; 
7     
8    public class TripletPanel extends JPanel { 
9        ObservablePoint3d op3d = new ObservablePoint3d(); 
10    
11       public TripletPanel() { 
12           setLayout(new GridLayout(0, 1)); 
13           add(new RunSlider() { 
14               public void run() { 
15                   op3d.setD1(getValue()); 
16               } 
17           }); 
18           add(new RunSlider() { 
19               public void run() { 
20                   op3d.setD2(getValue()); 
21               } 
22           }); 
23           add(new RunSlider() { 
24               public void run() { 
25                   op3d.setD3(getValue()); 
26               } 
27           }); 
28       } 
29    
30       public static JFrame getTripletFrame() { 
31           TripletPanel tp = new TripletPanel(); 
32           JFrame jf = new JFrame(); 
33           jf.setSize(200, 200); 
34           Container c = jf.getContentPane(); 
35           c.setLayout(new GridLayout(0, 1)); 
36           c.add(tp); 
37           jf.setVisible(true); 
38           return jf; 
39       } 
40    
41       public static void main(String args[]) { 
42           TripletPanel.getTripletFrame(); 
43       } 
44   } 
45