home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
WDESAMPL.BIN
/
ScrollTextSample.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
7KB
|
223 lines
/*
A basic extension of the java.applet.Applet class
*/
import java.awt.*;
import java.applet.*;
import symantec.itools.awt.HorizontalSlider;
import symantec.itools.multimedia.ScrollingText;
import symantec.itools.awt.util.spinner.NumericSpinner;
import symantec.itools.awt.DirectionButton;
import symantec.itools.awt.util.spinner.*;
import symantec.itools.multimedia.*;
import symantec.itools.awt.*;
public class ScrollTextSample 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 CardLayout(0,0));
setSize(529,240);
setFont(new Font("Dialog", Font.PLAIN, 12));
setForeground(new Color(0));
setBackground(new Color(12632256));
panel1 = new java.awt.Panel();
GridBagLayout gridBagLayout;
gridBagLayout = new GridBagLayout();
panel1.setLayout(gridBagLayout);
panel1.setBounds(0,0,529,240);
add("CardName", panel1);
textLabel = new java.awt.Label("Scroll Text",Label.RIGHT);
textLabel.setBounds(138,13,70,23);
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(textLabel, gbc);
panel1.add(textLabel);
textText = new java.awt.TextField(30);
textText.setText("Visual Cafe from Symantec");
textText.setBounds(218,13,172,23);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,10,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(textText, gbc);
panel1.add(textText);
unitLabel = new java.awt.Label("Scroll Unit",Label.RIGHT);
unitLabel.setBounds(138,70,70,23);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(unitLabel, gbc);
panel1.add(unitLabel);
unitSlider = new symantec.itools.awt.HorizontalSlider();
try {
unitSlider.setValue(10);
}
catch(java.beans.PropertyVetoException e) { }
try {
unitSlider.setTickStyle(symantec.itools.awt.HorizontalSlider.TICK_TOP);
}
catch(java.beans.PropertyVetoException e) { }
unitSlider.setBounds(218,60,116,43);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,10,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(unitSlider, gbc);
panel1.add(unitSlider);
panel5 = new java.awt.Panel();
panel5.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
panel5.setBounds(166,127,196,33);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.gridwidth = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(panel5, gbc);
panel1.add(panel5);
leftLabel = new java.awt.Label("Scroll Left");
leftLabel.setBounds(5,5,68,23);
panel5.add(leftLabel);
leftButton = new symantec.itools.awt.DirectionButton();
leftButton.setBounds(78,10,13,13);
panel5.add(leftButton);
rightButton = new symantec.itools.awt.DirectionButton();
try {
rightButton.setDirection(symantec.itools.awt.DirectionButton.RIGHT);
}
catch(java.beans.PropertyVetoException e) { }
rightButton.setBounds(96,10,13,13);
panel5.add(rightButton);
rightLabel = new java.awt.Label("Scroll Right");
rightLabel.setBounds(114,5,77,23);
panel5.add(rightLabel);
scrollText = new symantec.itools.multimedia.ScrollingText();
try {
scrollText.setScrollInterval(151);
}
catch(java.beans.PropertyVetoException e) { }
try {
java.lang.String[] tempString = new java.lang.String[1];
tempString[0] = new java.lang.String("Visual Cafe from Symantec");
scrollText.setMessageList(tempString);
}
catch(java.beans.PropertyVetoException e) { }
scrollText.setBounds(90,184,348,43);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,0);
((GridBagLayout)panel1.getLayout()).setConstraints(scrollText, gbc);
panel1.add(scrollText);
((CardLayout) getLayout()).show(this,"CardName");
//}}
//{{REGISTER_LISTENERS
Action lAction = new Action();
rightButton.addActionListener(lAction);
leftButton.addActionListener(lAction);
unitSlider.addActionListener(lAction);
textText.addActionListener(lAction);
//}}
}
//{{DECLARE_CONTROLS
java.awt.Panel panel1;
java.awt.Label textLabel;
java.awt.TextField textText;
java.awt.Label unitLabel;
symantec.itools.awt.HorizontalSlider unitSlider;
java.awt.Panel panel5;
java.awt.Label leftLabel;
symantec.itools.awt.DirectionButton leftButton;
symantec.itools.awt.DirectionButton rightButton;
java.awt.Label rightLabel;
symantec.itools.multimedia.ScrollingText scrollText;
//}}
class Action implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == rightButton)
rightButton_actionPerformed(event);
else if (object == leftButton)
leftButton_actionPerformed(event);
else if (object == unitSlider)
unitSlider_actionPerformed(event);
else if (object == textText)
textText_EnterHit(event);
}
}
void rightButton_actionPerformed(java.awt.event.ActionEvent event)
{
try {
// to do: place event handler code here.
if (scrollText != null)
scrollText.setScrollDirection(scrollText.SCROLL_RIGHT);
} catch(Exception e) {}
}
void leftButton_actionPerformed(java.awt.event.ActionEvent event)
{
try {
// to do: place event handler code here.
if (scrollText != null)
scrollText.setScrollDirection(scrollText.SCROLL_LEFT);
} catch(Exception e) {}
}
void unitSlider_actionPerformed(java.awt.event.ActionEvent event)
{
try {
// to do: place event handler code here.
if (scrollText != null)
scrollText.setScrollUnit(unitSlider.getValue());
} catch(Exception e) {}
}
void textText_EnterHit(java.awt.event.ActionEvent event)
{
try {
// to do: place event handler code here.
if (scrollText != null) {
String [] str = {textText.getText()};
scrollText.setMessageList(str);
}
} catch(Exception e) {}
}
}