home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
ThreadX.java
< prev
next >
Wrap
Text File
|
1998-10-29
|
9KB
|
326 lines
/*
A basic extension of the java.applet.Applet class
*/
import java.awt.*;
import java.applet.*;
public class ThreadX extends Applet {
public void init() {
super.init();
// Take out this line if you don't use symantec.itools.net.RelativeURL
symantec.itools.lang.Context.setDocumentBase(getDocumentBase());
//{{INIT_CONTROLS
setLayout(new BorderLayout(0,0));
setSize(507,300);
mainButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,20,10));
add("South", mainButtonPanel);
mainButtonPanel.setBounds(0,257,507,43);
startButton.setLabel("All Start");
mainButtonPanel.add(startButton);
startButton.setBounds(155,10,55,23);
stopButton.setLabel("All Stop");
mainButtonPanel.add(stopButton);
stopButton.setBounds(230,10,55,23);
resetButton.setLabel("Reset");
mainButtonPanel.add(resetButton);
resetButton.setBounds(305,10,47,23);
animationArea.setLayout(new GridLayout(1,3,0,0));
add("Center", animationArea);
animationArea.setBounds(0,0,507,257);
aPanel1.setLayout(new BorderLayout(0,0));
animationArea.add(aPanel1);
aPanel1.setBackground(java.awt.Color.red);
aPanel1.setBounds(0,0,169,257);
ap1.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
aPanel1.add("Center", ap1);
ap1.setBounds(0,0,169,224);
subP1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
aPanel1.add("South", subP1);
subP1.setBounds(0,224,169,33);
start1.setLabel("Start");
subP1.add(start1);
start1.setBounds(43,5,39,23);
stop1.setLabel("Stop");
subP1.add(stop1);
stop1.setBounds(87,5,39,23);
aPanel2.setLayout(new BorderLayout(0,0));
animationArea.add(aPanel2);
aPanel2.setBounds(169,0,169,257);
ap2.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
aPanel2.add("Center", ap2);
ap2.setBounds(0,0,169,224);
subP2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
aPanel2.add("South", subP2);
subP2.setBounds(0,224,169,33);
start2.setLabel("Start");
subP2.add(start2);
start2.setBounds(43,5,39,23);
stop2.setLabel("Stop");
subP2.add(stop2);
stop2.setBounds(87,5,39,23);
aPanel3.setLayout(new BorderLayout(0,0));
animationArea.add(aPanel3);
aPanel3.setBackground(java.awt.Color.blue);
aPanel3.setBounds(338,0,169,257);
ap3.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
aPanel3.add("Center", ap3);
ap3.setBounds(0,0,169,224);
subP3.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
aPanel3.add("South", subP3);
subP3.setBounds(0,224,169,33);
start3.setLabel("Start");
subP3.add(start3);
start3.setBounds(43,5,39,23);
stop3.setLabel("Stop");
subP3.add(stop3);
stop3.setBounds(87,5,39,23);
//}}
ap1.add(pa1);
ap2.add(pa2);
ap3.add(pa3);
//{{REGISTER_LISTENERS
SymAction lSymAction = new SymAction();
start1.addActionListener(lSymAction);
stop1.addActionListener(lSymAction);
start2.addActionListener(lSymAction);
stop2.addActionListener(lSymAction);
start3.addActionListener(lSymAction);
stop3.addActionListener(lSymAction);
startButton.addActionListener(lSymAction);
stopButton.addActionListener(lSymAction);
resetButton.addActionListener(lSymAction);
//}}
}
//{{DECLARE_CONTROLS
java.awt.Panel mainButtonPanel = new java.awt.Panel();
java.awt.Button startButton = new java.awt.Button();
java.awt.Button stopButton = new java.awt.Button();
java.awt.Button resetButton = new java.awt.Button();
java.awt.Panel animationArea = new java.awt.Panel();
java.awt.Panel aPanel1 = new java.awt.Panel();
java.awt.Panel ap1 = new java.awt.Panel();
java.awt.Panel subP1 = new java.awt.Panel();
java.awt.Button start1 = new java.awt.Button();
java.awt.Button stop1 = new java.awt.Button();
java.awt.Panel aPanel2 = new java.awt.Panel();
java.awt.Panel ap2 = new java.awt.Panel();
java.awt.Panel subP2 = new java.awt.Panel();
java.awt.Button start2 = new java.awt.Button();
java.awt.Button stop2 = new java.awt.Button();
java.awt.Panel aPanel3 = new java.awt.Panel();
java.awt.Panel ap3 = new java.awt.Panel();
java.awt.Panel subP3 = new java.awt.Panel();
java.awt.Button start3 = new java.awt.Button();
java.awt.Button stop3 = new java.awt.Button();
//}}
PolygonAnimation pa1 = new PolygonAnimation(100);
PolygonAnimation pa2 = new PolygonAnimation(120);
PolygonAnimation pa3 = new PolygonAnimation(150);
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == start1)
start1_ActionPerformed(event);
else if (object == stop1)
stop1_ActionPerformed(event);
else if (object == start2)
start2_ActionPerformed(event);
else if (object == stop2)
stop2_ActionPerformed(event);
else if (object == start3)
start3_ActionPerformed(event);
else if (object == stop3)
stop3_ActionPerformed(event);
else if (object == startButton)
startButton_ActionPerformed(event);
else if (object == stopButton)
stopButton_ActionPerformed(event);
else if (object == resetButton)
resetButton_ActionPerformed(event);
}
}
void start1_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
start1_ActionPerformed_Interaction1(event);
}
void start1_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa1.resume();
}
void stop1_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
stop1_ActionPerformed_Interaction1(event);
}
void stop1_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa1.stop();
}
void start2_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
start2_ActionPerformed_Interaction1(event);
}
void start2_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa2.resume();
}
void stop2_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
stop2_ActionPerformed_Interaction1(event);
}
void stop2_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa2.stop();
}
void start3_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
start3_ActionPerformed_Interaction1(event);
}
void start3_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa3.resume();
}
void stop3_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
stop3_ActionPerformed_Interaction1(event);
}
void stop3_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa3.stop();
}
void startButton_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
startButton_ActionPerformed_Interaction1(event);
startButton_ActionPerformed_Interaction2(event);
startButton_ActionPerformed_Interaction3(event);
}
void startButton_ActionPerformed_Interaction3(java.awt.event.ActionEvent event)
{
pa1.resume();
}
void startButton_ActionPerformed_Interaction2(java.awt.event.ActionEvent event)
{
pa2.resume();
}
void startButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa3.resume();
}
void stopButton_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
stopButton_ActionPerformed_Interaction1(event);
stopButton_ActionPerformed_Interaction2(event);
stopButton_ActionPerformed_Interaction3(event);
}
void stopButton_ActionPerformed_Interaction3(java.awt.event.ActionEvent event)
{
pa1.stop();
}
void stopButton_ActionPerformed_Interaction2(java.awt.event.ActionEvent event)
{
pa2.stop();
}
void stopButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa3.stop();
}
void resetButton_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
resetButton_ActionPerformed_Interaction1(event);
resetButton_ActionPerformed_Interaction2(event);
resetButton_ActionPerformed_Interaction3(event);
}
void resetButton_ActionPerformed_Interaction3(java.awt.event.ActionEvent event)
{
pa1.reset();
pa1.repaint();
}
void resetButton_ActionPerformed_Interaction2(java.awt.event.ActionEvent event)
{
pa2.reset();
pa2.repaint();
}
void resetButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
pa3.reset();
pa3.repaint();
}
}