001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2003 Fernando Damian Petrola
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: package examples;
019:
020: import java.awt.event.*;
021:
022: import javax.swing.*;
023:
024: import net.ar.webonswing.*;
025: import net.ar.webonswing.remote.*;
026: import net.ar.webonswing.swing.components.*;
027: import net.ar.webonswing.swing.layouts.*;
028: import examples.withtemplate.*;
029:
030: public class WebOnSwingDemo2 extends JFrame {
031: JPanel theMainPanel = null;
032: static int i = 0;
033:
034: public static void main(String[] args) {
035: new WebOnSwingDemo2().setVisible(true);
036: }
037:
038: public WebOnSwingDemo2() {
039: addComponents();
040: }
041:
042: public void addComponents() {
043: final JLabel theLabel1 = new JLabel("label 1");
044: theLabel1.setLayout(new TemplateLayout(WosFramework
045: .getKeyPositionTemplateForName("Label1")));
046: theLabel1.setIcon(new ImageIcon("resources/images/Rabbit.gif"));
047:
048: final JLabel theLabel2 = new JLabel("label inside");
049: final JButton theCountButton = new JButton("Count Button");
050:
051: ActionListener action = new ActionListener() {
052: public void actionPerformed(ActionEvent e) {
053: theCountButton.setText("button value= " + ++i);
054: theLabel2.setText("label value= " + i);
055: TemplateCheckBoxDemo theCheckBoxDemo = new TemplateCheckBoxDemo(
056: WebOnSwingDemo2.this , true);
057: theCheckBoxDemo.setModal(true);
058:
059: // WindowManager.showWindow(WebOnSwingDemo2.this, new WebPage("http://localhost:8080/WosExamples/WebOnSwingDemo.page"));
060: //theCheckBoxDemo.show();
061: WosFramework.showChildWindow(WebOnSwingDemo2.this ,
062: theCheckBoxDemo);
063: }
064: };
065:
066: ActionListener action2 = new ActionListener() {
067: public void actionPerformed(ActionEvent e) {
068: theLabel2.setText("clicks= " + i++);
069: }
070: };
071:
072: JButton theButton = new JButton("Goto TemplateCheckBoxDemo");
073: theButton.addActionListener(action);
074:
075: theCountButton.addActionListener(action2);
076:
077: JPanel theBodyPanel = new JPanel(
078: new TemplateLayout(
079: WosFramework
080: .getKeyPositionTemplateForName("WebOnSwingDemo2Body")));
081:
082: theBodyPanel.add(theButton, "theCheckDemo");
083: theBodyPanel.add(theCountButton, "theCountButton");
084: theBodyPanel.add(theLabel2, "theLabel2");
085:
086: theBodyPanel.add(theLabel1, "theBucket2");
087:
088: JLink unLink = new JLink("Goto TemplateRadioButtonDemo",
089: TemplateRadioButtonDemo.class);
090:
091: class LinkMouseMotion implements MouseMotionListener,
092: RemoteListener {
093: public void mouseDragged(MouseEvent e) {
094: }
095:
096: public void mouseMoved(MouseEvent e) {
097: }
098:
099: public String getRemoteName() {
100: return "ChangeLinkColor";
101: }
102:
103: public Object[] getRemoteParameters() {
104: return new Object[0];
105: }
106: }
107: unLink.addMouseMotionListener(new LinkMouseMotion());
108:
109: theBodyPanel.add(unLink, "theLink1");
110:
111: DefaultComboBoxModel theModel = new DefaultComboBoxModel();
112: theModel.addElement("first");
113: theModel.addElement("second");
114: theModel.addElement("third");
115:
116: DefaultComboBoxModel theModel2 = new DefaultComboBoxModel();
117: theModel2.addElement("element1");
118: theModel2.addElement("element2");
119: theModel2.addElement("element3");
120:
121: DefaultListModel theListModel = new DefaultListModel();
122: theListModel.addElement("list element 1");
123: theListModel.addElement("list element 2");
124: theListModel.addElement("list element 3");
125: theListModel.addElement("list element 4");
126:
127: JList theList = new JList(theListModel);
128: theList.putClientProperty("theContributor",
129: WebOnSwingDemo2Contributor.class.getName());
130:
131: JPanel theTable = new JPanel(new TemplateLayout(WosFramework
132: .getKeyPositionTemplateForName("TableTest")));
133: JPanel theGrid = new JPanel(new TemplateGridLayout(3, 3,
134: WosFramework.getKeyPositionTemplateForName("RowTest"),
135: WosFramework.getKeyPositionTemplateForName("RowTest2")));
136: theGrid.add(new JButton("button 1"));
137: theGrid.add(new JComboBox(theModel2));
138: theGrid.add(new JCheckBox("check 1"));
139: theGrid.add(theList);
140: theGrid.add(new JButton("button 2"));
141: theGrid.add(new JCheckBox("a check 1"));
142: theTable.add(theGrid, "theContent");
143: theBodyPanel.add(theTable, "theElement1");
144:
145: theBodyPanel.add(
146: new TemplateRadioButtonDemo.RadioButtonDemoPanel(),
147: "theElement3");
148: theBodyPanel.add(new JComboBox(theModel), "theComboBox");
149: theBodyPanel.add(new TemplateCheckBoxDemo.CheckBoxDemoPanel(),
150: "otroPanel");
151: theBodyPanel
152: .add(
153: new JWosReloader(
154: new TemplateLayout(
155: WosFramework
156: .getKeyPositionTemplateForName("JWosReloader"))),
157: "theElement2");
158:
159: theMainPanel = new JPanel(new TemplateLayout(WosFramework
160: .getKeyPositionTemplateForName("Label1")));
161:
162: theMainPanel.add(new JLabel("WebOnSwing Demo"), "theLabel");
163: theMainPanel.add(theBodyPanel, "theImage");
164:
165: setContentPane(theMainPanel);
166:
167: /*
168: show();
169: pack();
170: */
171: }
172: }
|