home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / ScrollTextSample.java < prev    next >
Text File  |  1998-10-31  |  7KB  |  205 lines

  1. /*  
  2.     A basic extension of the java.applet.Applet class
  3.  */
  4.  
  5. import java.awt.*;
  6. import java.applet.*;
  7.  
  8. import symantec.itools.awt.HorizontalSlider;
  9. import symantec.itools.multimedia.ScrollingText;
  10. import symantec.itools.awt.util.spinner.NumericSpinner;
  11. import symantec.itools.awt.DirectionButton;
  12. import symantec.itools.awt.util.spinner.*;
  13. import symantec.itools.multimedia.*;
  14. import symantec.itools.awt.*;
  15. public class ScrollTextSample extends Applet {
  16.     public void init() {
  17.         super.init();
  18.  
  19.         // Take out this line if you don't use symantec.itools.net.RelativeURL
  20.         // symantec.itools.lang.Context.setDocumentBase(getDocumentBase());
  21.  
  22.         //{{INIT_CONTROLS
  23.         setLayout(new CardLayout(0,0));
  24.         setSize(529,240);
  25.         setFont(new Font("Dialog", Font.PLAIN, 12));
  26.         setForeground(java.awt.Color.black);
  27.         setBackground(java.awt.Color.lightGray);
  28.         panel1.setLayout(new GridBagLayout());
  29.         panel1.setBounds(0,0,529,240);
  30.         add("CardName", panel1);
  31.         textLabel.setText("Scroll Text");
  32.         textLabel.setAlignment(java.awt.Label.RIGHT);
  33.         textLabel.setBounds(138,13,70,23);
  34.         panel1.add(textLabel, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  35.         textText.setText("Visual Cafe from Symantec");
  36.         textText.setBounds(218,13,172,23);
  37.         panel1.add(textText, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,10,0,0),0,0));
  38.         unitLabel.setText("Scroll Unit");
  39.         unitLabel.setAlignment(java.awt.Label.RIGHT);
  40.         unitLabel.setBounds(138,70,70,23);
  41.         panel1.add(unitLabel, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  42.         try {
  43.             unitSlider.setValue(10);
  44.         }
  45.         catch(java.beans.PropertyVetoException e) { }
  46.         try {
  47.             unitSlider.setTickStyle(symantec.itools.awt.HorizontalSlider.TICK_TOP);
  48.         }
  49.         catch(java.beans.PropertyVetoException e) { }
  50.         unitSlider.setBounds(218,60,116,43);
  51.         panel1.add(unitSlider, new com.symantec.itools.awt.GridBagConstraintsD(1,1,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,10,0,0),0,0));
  52.         panel5.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  53.         panel5.setBounds(166,127,196,33);
  54.         panel1.add(panel5, new com.symantec.itools.awt.GridBagConstraintsD(0,3,2,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  55.         leftLabel.setText("Scroll Left");
  56.         leftLabel.setBounds(5,5,68,23);
  57.         panel5.add(leftLabel);
  58.         leftButton.setBounds(78,10,13,13);
  59.         panel5.add(leftButton);
  60.         try {
  61.             rightButton.setDirection(symantec.itools.awt.DirectionButton.RIGHT);
  62.         }
  63.         catch(java.beans.PropertyVetoException e) { }
  64.         rightButton.setBounds(96,10,13,13);
  65.         panel5.add(rightButton);
  66.         rightLabel.setText("Scroll Right");
  67.         rightLabel.setBounds(114,5,77,23);
  68.         panel5.add(rightLabel);
  69.         try {
  70.             scrollText.setScrollInterval(151);
  71.         }
  72.         catch(java.beans.PropertyVetoException e) { }
  73.         try {
  74.             {
  75.                 String[] tempString = new String[1];
  76.                 tempString[0] = "Visual Cafe from Symantec";
  77.                 scrollText.setMessageList(tempString);
  78.             }
  79.         }
  80.         catch(java.beans.PropertyVetoException e) { }
  81.         scrollText.setBounds(90,184,348,43);
  82.         panel1.add(scrollText, new com.symantec.itools.awt.GridBagConstraintsD(0,4,2,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  83.         ((CardLayout) getLayout()).show(this,"CardName");
  84.         //}}
  85.             
  86.         //{{REGISTER_LISTENERS
  87.         SymAction lSymAction = new SymAction();
  88.         leftButton.addActionListener(lSymAction);
  89.         rightButton.addActionListener(lSymAction);
  90.         unitSlider.addActionListener(lSymAction);
  91.         textText.addActionListener(lSymAction);
  92.         //}}
  93.  
  94.     }
  95.  
  96.     //{{DECLARE_CONTROLS
  97.     java.awt.Panel panel1 = new java.awt.Panel();
  98.     java.awt.Label textLabel = new java.awt.Label();
  99.     java.awt.TextField textText = new java.awt.TextField(30);
  100.     java.awt.Label unitLabel = new java.awt.Label();
  101.     symantec.itools.awt.HorizontalSlider unitSlider = new symantec.itools.awt.HorizontalSlider();
  102.     java.awt.Panel panel5 = new java.awt.Panel();
  103.     java.awt.Label leftLabel = new java.awt.Label();
  104.     symantec.itools.awt.DirectionButton leftButton = new symantec.itools.awt.DirectionButton();
  105.     symantec.itools.awt.DirectionButton rightButton = new symantec.itools.awt.DirectionButton();
  106.     java.awt.Label rightLabel = new java.awt.Label();
  107.     symantec.itools.multimedia.ScrollingText scrollText = new symantec.itools.multimedia.ScrollingText();
  108.     //}}
  109.  
  110.  
  111.  
  112.     
  113.  
  114.  
  115.  
  116.     class SymAction implements java.awt.event.ActionListener
  117.     {
  118.         public void actionPerformed(java.awt.event.ActionEvent event)
  119.         {
  120.             Object object = event.getSource();
  121.             if (object == leftButton)
  122.                 leftButton_actionPerformed(event);
  123.             else if (object == rightButton)
  124.                 rightButton_actionPerformed(event);
  125.             else if (object == unitSlider)
  126.                 unitSlider_actionPerformed(event);
  127.             else if (object == textText)
  128.                 textText_ActionPerformed(event);
  129.         }
  130.     }
  131.  
  132.     void leftButton_actionPerformed(java.awt.event.ActionEvent event)
  133.     {
  134.         // to do: code goes here.
  135.              
  136.         leftButton_actionPerformed_Interaction1(event);
  137.     }
  138.  
  139.  
  140.     void leftButton_actionPerformed_Interaction1(java.awt.event.ActionEvent event)
  141.     {
  142.         try {
  143.             // scrollText SCROLL_LEFT
  144.             scrollText.setScrollDirection(scrollText.SCROLL_LEFT);
  145.         } catch (Exception e) {
  146.         }
  147.     }
  148.  
  149.  
  150.     void rightButton_actionPerformed(java.awt.event.ActionEvent event)
  151.     {
  152.         // to do: code goes here.
  153.              
  154.         rightButton_actionPerformed_Interaction1(event);
  155.     }
  156.  
  157.  
  158.     void rightButton_actionPerformed_Interaction1(java.awt.event.ActionEvent event)
  159.     {
  160.         try {
  161.             // scrollText SCROLL_RIGHT
  162.             scrollText.setScrollDirection(scrollText.SCROLL_RIGHT);
  163.         } catch (Exception e) {
  164.         }
  165.     }
  166.  
  167.  
  168.     void unitSlider_actionPerformed(java.awt.event.ActionEvent event)
  169.     {
  170.         // to do: code goes here.
  171.              
  172.         unitSlider_actionPerformed_Interaction1(event);
  173.     }
  174.  
  175.  
  176.     void unitSlider_actionPerformed_Interaction1(java.awt.event.ActionEvent event)
  177.     {
  178.         try {
  179.             // unitSlider Get the current value of the HorizontalSlider
  180.             scrollText.setScrollUnit(unitSlider.getValue());
  181.         } catch (Exception e) {
  182.         }
  183.     }
  184.  
  185.  
  186.     void textText_ActionPerformed(java.awt.event.ActionEvent event)
  187.     {
  188.         // to do: code goes here.
  189.              
  190.         textText_ActionPerformed_Interaction1(event);
  191.     }
  192.  
  193.  
  194.     void textText_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  195.     {
  196.         try {
  197.             if (scrollText != null) {
  198.                 String [] str = {textText.getText()};
  199.                 scrollText.setMessageList(str);
  200.             }
  201.         } catch(Exception e) {}
  202.     }
  203.  
  204. }
  205.