home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
WDESAMPL.BIN
/
SoundPlayerClass.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
6KB
|
195 lines
/*
A basic extension of the java.awt.Frame class
*/
import java.awt.*;
import symantec.itools.multimedia.*;
import symantec.itools.util.Timer;
import symantec.itools.awt.*;
import symantec.itools.awt.ImageButton;
import symantec.itools.multimedia.SoundPlayer;
import symantec.itools.multimedia.ImageViewer;
public class SoundPlayerClass extends Frame
{
public SoundPlayerClass()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setVisible(false);
setSize(430,270);
setBackground(new Color(12632256));
soundPlayer1 = new symantec.itools.multimedia.SoundPlayer();
try {
java.net.URL[] tempURL = new java.net.URL[5];
tempURL[0] = symantec.itools.net.RelativeURL.getURL("sounds/T1.au");
tempURL[1] = symantec.itools.net.RelativeURL.getURL("sounds/T2.au");
tempURL[2] = symantec.itools.net.RelativeURL.getURL("sounds/T3.au");
tempURL[3] = symantec.itools.net.RelativeURL.getURL("sounds/T4.au");
tempURL[4] = symantec.itools.net.RelativeURL.getURL("sounds/T5.au");
soundPlayer1.setURLList(tempURL);
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
//$$ soundPlayer1.move(212,61);
imageViewer1 = new symantec.itools.multimedia.ImageViewer();
try {
imageViewer1.setImageURL(symantec.itools.net.RelativeURL.getURL("images/right.gif"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
imageViewer1.setBounds(42,7,136,131);
add(imageViewer1);
imageViewer2 = new symantec.itools.multimedia.ImageViewer();
try {
imageViewer2.setImageURL(symantec.itools.net.RelativeURL.getURL("images/right.gif"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
imageViewer2.setBounds(251,7,136,131);
add(imageViewer2);
imageButton1 = new symantec.itools.awt.ImageButton();
try {
imageButton1.setImageURL(symantec.itools.net.RelativeURL.getURL("images/stop.gif"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
imageButton1.setBounds(136,145,57,58);
add(imageButton1);
imageButton2 = new symantec.itools.awt.ImageButton();
try {
imageButton2.setImageURL(symantec.itools.net.RelativeURL.getURL("images/play.gif"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
imageButton2.setBounds(240,145,57,58);
add(imageButton2);
setTitle("Sound Player");
//}}
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymComponent aSymComponent = new SymComponent();
SymAction lSymAction = new SymAction();
imageButton1.addActionListener(lSymAction);
imageButton2.addActionListener(lSymAction);
//}}
}
public SoundPlayerClass(String title)
{
this();
setTitle(title);
}
public synchronized void show()
{
move(50, 50);
super.show();
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets().left, insets().top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
symantec.itools.multimedia.SoundPlayer soundPlayer1;
symantec.itools.multimedia.ImageViewer imageViewer1;
symantec.itools.multimedia.ImageViewer imageViewer2;
symantec.itools.awt.ImageButton imageButton1;
symantec.itools.awt.ImageButton imageButton2;
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == SoundPlayerClass.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
hide(); // hide the Frame
}
class SymComponent extends java.awt.event.ComponentAdapter
{
public void componentHidden(java.awt.event.ComponentEvent event)
{
Object object = event.getSource();
}
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == imageButton1)
imageButton1_actionPerformed(event);
else if (object == imageButton2)
imageButton2_actionPerformed(event);
}
}
void imageButton1_actionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
//{{CONNECTION
// Stop the sound player
{
soundPlayer1.stop();
}
//}}
}
void imageButton2_actionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
//{{CONNECTION
// Start the sound player
{
soundPlayer1.play();
}
//}}
}
}