home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
TestBdk.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
11KB
|
327 lines
package borland.samples.bdk;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.beans.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import sunw.demo.buttons.*;
import sunw.demo.juggler.*;
import jclass.bwt.*;
import sunw.demo.jelly.*;
import sunw.demo.misc.*;
import sunw.demo.test.*;
import sunw.demo.molecule.*;
public class TestBdk extends Applet {
static final int INITIAL_ANIMATION = 300;
XYLayout xYLayout1 = new XYLayout();
boolean isStandalone = false;
TabsetPanel tabsetPanel1 = new TabsetPanel();
BevelPanel bevelPanel1 = new BevelPanel();
BevelPanel bevelPanel2 = new BevelPanel();
BevelPanel bevelPanel3 = new BevelPanel();
OurButton ourButton1 = new OurButton();
//Designer generated code for Juggler bean
//Juggler juggler1 = new Juggler();
//Replacement to use beans.instantiate
Juggler juggler1;
Button start = new Button();
Button stop = new Button();
JCSlider jCSlider1 = new JCSlider();
JellyBean jellyBean1 = new JellyBean();
ChangeReporter changeReporter1 = new ChangeReporter();
Button changeColor = new Button();
ColorChooser colorChooser1 = new ColorChooser();
Label label1 = new Label();
Voter voter1 = new Voter();
Button vote = new Button();
Button changePrice = new Button();
ExplicitButton explicitButton1 = new ExplicitButton();
BevelPanel bevelPanel4 = new BevelPanel();
BridgeTester bridgeTester1 = new BridgeTester();
ChangeReporter changeReporter2 = new ChangeReporter();
XYLayout xYLayout2 = new XYLayout();
BevelPanel bevelPanel5 = new BevelPanel();
Molecule molecule1 = new Molecule();
ChoiceControl choiceControl1 = new ChoiceControl();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public TestBdk() {
}
//Initialize the applet
public void init() {
try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
}
//Component initialization
public void jbInit() throws Exception{
xYLayout1.setWidth(400);
xYLayout1.setHeight(300);
this.setLayout(xYLayout1);
this.add(tabsetPanel1, new XYConstraints(12, 13, 373, 270));
//Buttons setup
ourButton1.setLabel("ourButton1");
explicitButton1.setLabel("explicitButton1");
bevelPanel1.add(ourButton1, new XYConstraints(12, 9, 87, 37));
bevelPanel1.add(explicitButton1, new XYConstraints(116, 8, 93, 40));
tabsetPanel1.add(bevelPanel1, "Buttons");
//Juggler setup
//Required for beans which need an Applet context to run
juggler1 = (Juggler)Beans.instantiate(null,"sunw.demo.juggler.Juggler");
juggler1.setAnimationRate(INITIAL_ANIMATION);
start.setLabel("Start");
start.addActionListener(new TestBdk_start_actionAdapter(this));
stop.setLabel("Stop");
stop.addActionListener(new TestBdk_stop_actionAdapter(this));
jCSlider1.setMaximum(INITIAL_ANIMATION);
jCSlider1.setMaximumLabelString("Slow");
jCSlider1.setMinimum(50);
jCSlider1.setMinimumLabelString("Fast");
jCSlider1.setOrientation(jclass.bwt.BWTEnum.VERTICAL);
jCSlider1.setValue(INITIAL_ANIMATION);
jCSlider1.addAdjustmentListener(new TestBdk_jCSlider1_adjustmentAdapter(this));
bevelPanel2.add(juggler1, new XYConstraints(9, 8, 146, 126));
bevelPanel2.add(start, new XYConstraints(7, 147, 60, 27));
bevelPanel2.add(stop, new XYConstraints(85, 148, 66, 27));
bevelPanel2.add(jCSlider1, new XYConstraints(166, 8, 45, 168));
tabsetPanel1.add(bevelPanel2, "Juggler");
//Jellybean setup
jellyBean1.addVetoableChangeListener(new TestBdk_jellyBean1_vetoableChangeAdapter(this));
changeColor.setLabel("Change Color");
label1.setText("Change Reporter");
voter1.setVisible(false);
voter1.setBackground(Color.lightGray);
voter1.setVetoAll(false);
vote.setLabel("Veto price Change");
changePrice.setLabel("Change Price");
bevelPanel4.setLayout(xYLayout2);
changePrice.addActionListener(new TestBdk_changePrice_actionAdapter(this));
vote.addActionListener(new TestBdk_vote_actionAdapter(this));
changeColor.addActionListener(new TestBdk_changeColor_actionAdapter(this));
jellyBean1.addPropertyChangeListener(new TestBdk_jellyBean1_propertyChangeAdapter(this));
bevelPanel3.add(jellyBean1, new XYConstraints(132, 15, 58, -1));
bevelPanel3.add(changeReporter1, new XYConstraints(7, 76, 334, 24));
bevelPanel3.add(changeColor, new XYConstraints(6, 111, 98, 30));
bevelPanel3.add(label1, new XYConstraints(112, 56, 113, 19));
bevelPanel3.add(voter1, new XYConstraints(206, 18, 73, 50));
bevelPanel3.add(vote, new XYConstraints(111, 147, 114, 30));
bevelPanel3.add(changePrice, new XYConstraints(7, 148, 98, 30));
tabsetPanel1.add(bevelPanel3, "Jelly Bean");
//Bridge Tester
bridgeTester1.addPropertyChangeListener(new TestBdk_bridgeTester1_propertyChangeAdapter(this));
bevelPanel4.add(bridgeTester1, new XYConstraints(9, 13, 342, 168));
bevelPanel4.add(changeReporter2, new XYConstraints(4, 207, 348, -1));
tabsetPanel1.add(bevelPanel4, "Bridge Tester");
//Molecule
tabsetPanel1.add(bevelPanel5, "Molecule");
bevelPanel5.add(molecule1, new XYConstraints(67, 18, 208, 154));
bevelPanel5.add(choiceControl1, new XYConstraints(66, 182, 211, 29));
//Use the property editor from the Molecule bean to get the name []
//for our choice control
choiceControl1.setItems(new MoleculeNameEditor().getTags());
choiceControl1.addItemListener(new TestBdk_choiceControl1_itemAdapter(this));
tabsetPanel1.setSelectedIndex(0);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
void start_actionPerformed(ActionEvent e) {
juggler1.start();
}
void stop_actionPerformed(ActionEvent e) {
juggler1.stop();
}
void jCSlider1_adjustmentValueChanged(JCAdjustmentEvent e) {
juggler1.setAnimationRate(e.getValue());
}
//Example of bound properties
void jellyBean1_propertyChange(PropertyChangeEvent e) {
changeReporter1.reportChange(e);
}
//Changing the color property should result in the change reporter
//being notified through the propertyChange event
void changeColor_actionPerformed(ActionEvent e) {
colorChooser1.setFrame(new Frame());
colorChooser1.show();
jellyBean1.setColor(colorChooser1.getValue());
}
//Let voter determine if property can be set
void jellyBean1_vetoableChange(PropertyChangeEvent e) throws PropertyVetoException{
voter1.vetoableChange(e);
}
//Toggles the voter component
void vote_actionPerformed(ActionEvent e) {
if (voter1.getVetoAll()) {
vote.setLabel("Veto price change");
voter1.setVetoAll(false);
} else {
vote.setLabel("Accept price change");
voter1.setVetoAll(true);
}
}
void changePrice_actionPerformed(ActionEvent e) {
try {
jellyBean1.setPriceInCents(jellyBean1.getPriceInCents()+1);
} catch (Exception x) {x.printStackTrace();}
}
void bridgeTester1_propertyChange(PropertyChangeEvent e) {
changeReporter2.reportChange(e);
}
void choiceControl1_itemStateChanged(ItemEvent e) {
molecule1.setMoleculeName(choiceControl1.getSelectedItem());
}
}
class TestBdk_start_actionAdapter implements java.awt.event.ActionListener {
TestBdk adaptee;
TestBdk_start_actionAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.start_actionPerformed(e);
}
}
class TestBdk_stop_actionAdapter implements java.awt.event.ActionListener {
TestBdk adaptee;
TestBdk_stop_actionAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.stop_actionPerformed(e);
}
}
class TestBdk_jCSlider1_adjustmentAdapter implements jclass.bwt.JCAdjustmentListener {
TestBdk adaptee;
TestBdk_jCSlider1_adjustmentAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void adjustmentValueChanged(JCAdjustmentEvent e) {
adaptee.jCSlider1_adjustmentValueChanged(e);
}
}
class TestBdk_jellyBean1_propertyChangeAdapter implements java.beans.PropertyChangeListener{
TestBdk adaptee;
TestBdk_jellyBean1_propertyChangeAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void propertyChange(PropertyChangeEvent e) {
adaptee.jellyBean1_propertyChange(e);
}
}
class TestBdk_changeColor_actionAdapter implements java.awt.event.ActionListener {
TestBdk adaptee;
TestBdk_changeColor_actionAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.changeColor_actionPerformed(e);
}
}
class TestBdk_jellyBean1_vetoableChangeAdapter implements java.beans.VetoableChangeListener {
TestBdk adaptee;
TestBdk_jellyBean1_vetoableChangeAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException{
adaptee.jellyBean1_vetoableChange(e);
}
}
class TestBdk_vote_actionAdapter implements java.awt.event.ActionListener {
TestBdk adaptee;
TestBdk_vote_actionAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.vote_actionPerformed(e);
}
}
class TestBdk_changePrice_actionAdapter implements java.awt.event.ActionListener {
TestBdk adaptee;
TestBdk_changePrice_actionAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.changePrice_actionPerformed(e);
}
}
class TestBdk_bridgeTester1_propertyChangeAdapter implements java.beans.PropertyChangeListener {
TestBdk adaptee;
TestBdk_bridgeTester1_propertyChangeAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void propertyChange(PropertyChangeEvent e) {
adaptee.bridgeTester1_propertyChange(e);
}
}
class TestBdk_choiceControl1_itemAdapter implements java.awt.event.ItemListener {
TestBdk adaptee;
TestBdk_choiceControl1_itemAdapter(TestBdk adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.choiceControl1_itemStateChanged(e);
}
}