01: /*
02: * Copyright 2006 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13:
14: package org.wingx.example;
15:
16: import javax.swing.event.ChangeEvent;
17: import org.wings.SComponent;
18: import org.wings.SDimension;
19: import org.wings.SFrame;
20: import org.wings.SPanel;
21: import org.wings.plaf.WingSetExample;
22: import org.wings.border.SLineBorder;
23: import org.wings.event.SAjaxChangeListener;
24: import org.wings.script.JavaScriptDOMListener;
25: import org.wings.script.JavaScriptEvent;
26: import org.wingx.XColorPicker;
27: import org.wingx.XPopupFrame;
28:
29: /**
30: * Example demonstrating the use of component XPopupFrame.
31: * @author Christian Schyma
32: */
33: public class XPopupFrameExperiment implements WingSetExample {
34: private SPanel panel;
35:
36: public void activateExample() {
37: panel = new SPanel();
38:
39: SFrame f = new SFrame();
40: XColorPicker picker = new XColorPicker(0, 0, 0);
41: f.getContentPane().add(picker);
42:
43: XPopupFrame popupFrame = new XPopupFrame(f, 400, 300);
44: panel.add(popupFrame);
45:
46: final SPanel colorPanel = new SPanel();
47: colorPanel.setBorder(new SLineBorder(1));
48: colorPanel.setPreferredSize(new SDimension(50, 50));
49: colorPanel.setToolTipText("click me!");
50: colorPanel.addScriptListener(new JavaScriptDOMListener(
51: JavaScriptEvent.ON_CLICK, popupFrame.showScript(),
52: colorPanel));
53: panel.add(colorPanel);
54:
55: picker.addAjaxChangeListener(new SAjaxChangeListener() {
56: public void stateChanged(ChangeEvent e) {
57: colorPanel.setBackground(((XColorPicker) e.getSource())
58: .getSelectedColor());
59: }
60: });
61: }
62:
63: public void passivateExample() {
64: //To change body of implemented methods use File | Settings | File Templates.
65: }
66:
67: public SComponent getExample() {
68: return panel;
69: }
70:
71: public String getExampleName() {
72: return "XPopupFrame";
73: }
74:
75: public String getExampleGroup() {
76: return "Experiment";
77: }
78: }
|