home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / ScrollTextSample.java < prev    next >
Encoding:
Java Source  |  1996-12-13  |  5.6 KB  |  169 lines

  1. /*  
  2.     A basic extension of the java.applet.Applet class
  3.  */
  4.  
  5. import java.awt.*;
  6. import java.applet.*;
  7.  
  8. public class ScrollTextSample extends Applet {
  9.     void rightButton_Action(Event event) {
  10.         // to do: place event handler code here.
  11.         if (scrollText != null)
  12.             scrollText.setScrollDirection(ScrollText.SCROLL_RIGHT);
  13.     }
  14.  
  15.     void leftButton_Action(Event event) {
  16.         // to do: place event handler code here.
  17.         if (scrollText != null)
  18.             scrollText.setScrollDirection(ScrollText.SCROLL_LEFT);
  19.     }
  20.  
  21.     void intervalSpinner_Action(Event event) {
  22.         // to do: place event handler code here.
  23.         if (scrollText != null)
  24.             scrollText.setScrollInterval(intervalSpinner.getCurrent());
  25.     }
  26.  
  27.     void unitSlider_Action(Event event) {
  28.         // to do: place event handler code here.
  29.         if (scrollText != null)
  30.             scrollText.setScrollUnit(unitSlider.getValue());
  31.     }
  32.  
  33.     void textText_EnterHit(Event event) {
  34.         // to do: place event handler code here.
  35.         if (scrollText != null)
  36.             scrollText.setText(textText.getText());
  37.     }
  38.  
  39.  
  40.     public void init() {
  41.         super.init();
  42.  
  43.         // Take out this line if you don't use symantec.itools.net.RelativeURL
  44.         // symantec.itools.lang.Context.setDocumentBase(getDocumentBase());
  45.  
  46.         //{{INIT_CONTROLS
  47.         setLayout(new BorderLayout(0,0));
  48.         addNotify();
  49.         resize(319,265);
  50.         setBackground(new Color(12632256));
  51.         panel1 = new java.awt.Panel();
  52.         panel1.setLayout(new GridLayout(4,1,5,5));
  53.         panel1.reshape(0,0,319,265);
  54.         add("Center", panel1);
  55.         textPanel = new java.awt.Panel();
  56.         textPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  57.         textPanel.reshape(0,0,319,62);
  58.         panel1.add(textPanel);
  59.         textlabel = new java.awt.Label("Scroll Text");
  60.         textlabel.reshape(34,5,75,21);
  61.         textPanel.add(textlabel);
  62.         textText = new java.awt.TextField();
  63.         textText.setText("Visual Cafe from Symantec");
  64.         textText.reshape(114,5,171,21);
  65.         textPanel.add(textText);
  66.         unitPanel = new java.awt.Panel();
  67.         unitPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  68.         unitPanel.reshape(0,67,319,62);
  69.         panel1.add(unitPanel);
  70.         unitLabel = new java.awt.Label("Scroll Unit  ");
  71.         unitLabel.reshape(76,17,81,21);
  72.         unitPanel.add(unitLabel);
  73.         unitSlider = new symantec.itools.awt.HorizontalSlider();
  74.         unitSlider.reshape(162,5,80,45);
  75.         unitSlider.setBackground(new Color(16777215));
  76.         unitPanel.add(unitSlider);
  77.         unitSlider.setMinValue(5);
  78.         unitSlider.setMaxValue(30);
  79.         unitSlider.setTickFreq(5);
  80.         unitSlider.setValue(10);
  81.         unitSlider.setTickStyle(symantec.itools.awt.HorizontalSlider.TICK_TOP);
  82.         intervalPanel = new java.awt.Panel();
  83.         intervalPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  84.         intervalPanel.reshape(0,134,319,62);
  85.         panel1.add(intervalPanel);
  86.         intervalLabel = new java.awt.Label("Scroll Interval");
  87.         intervalLabel.reshape(71,10,93,21);
  88.         intervalPanel.add(intervalLabel);
  89.         intervalSpinner = new symantec.itools.awt.NumericSpinner();
  90.         intervalSpinner.reshape(169,5,79,32);
  91.         intervalPanel.add(intervalSpinner);
  92.         intervalSpinner.setMin(50);
  93.         intervalSpinner.setMax(300);
  94.         intervalSpinner.setCurrent(150);
  95.         intervalSpinner.setIncrement(10);
  96.         directionPanel = new java.awt.Panel();
  97.         directionPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  98.         directionPanel.reshape(0,201,319,62);
  99.         panel1.add(directionPanel);
  100.         leftLabel = new java.awt.Label("Scroll left   ");
  101.         leftLabel.reshape(52,5,80,21);
  102.         directionPanel.add(leftLabel);
  103.         leftButton = new symantec.itools.awt.DirectionButton();
  104.         leftButton.reshape(137,5,20,20);
  105.         directionPanel.add(leftButton);
  106.         rightButton = new symantec.itools.awt.DirectionButton();
  107.         rightButton.reshape(162,5,20,20);
  108.         directionPanel.add(rightButton);
  109.         rightButton.setDirection(symantec.itools.awt.DirectionButton.RIGHT);
  110.         rightLabel = new java.awt.Label("Scroll Right");
  111.         rightLabel.reshape(187,5,80,21);
  112.         directionPanel.add(rightLabel);
  113.         //}}
  114.         
  115.         // Create the ScrollText at the bottom of the applet
  116.         // Also change the font so it is more noticable
  117.         scrollText = new ScrollText();
  118.         scrollText.reshape(0,100,200,50);
  119.         scrollText.setFont(new Font("Dialog", Font.BOLD, 16));
  120.         add("South", scrollText);
  121.     }
  122.  
  123.     public boolean handleEvent(Event event) {
  124.         if (event.target == textText && event.id == Event.ACTION_EVENT) {
  125.             textText_EnterHit(event);
  126.             return true;
  127.         }
  128.         if (event.target == unitSlider && event.id == Event.ACTION_EVENT) {
  129.             unitSlider_Action(event);
  130.             return true;
  131.         }
  132.         if (event.target == intervalSpinner && event.id == Event.ACTION_EVENT) {
  133.             intervalSpinner_Action(event);
  134.             return true;
  135.         }
  136.         if (event.target == leftButton && event.id == Event.ACTION_EVENT) {
  137.             leftButton_Action(event);
  138.             return true;
  139.         }
  140.         if (event.target == rightButton && event.id == Event.ACTION_EVENT) {
  141.             rightButton_Action(event);
  142.             return true;
  143.         }
  144.         return super.handleEvent(event);
  145.     }
  146.  
  147.     //{{DECLARE_CONTROLS
  148.     java.awt.Panel panel1;
  149.     java.awt.Panel textPanel;
  150.     java.awt.Label textlabel;
  151.     java.awt.TextField textText;
  152.     java.awt.Panel unitPanel;
  153.     java.awt.Label unitLabel;
  154.     symantec.itools.awt.HorizontalSlider unitSlider;
  155.     java.awt.Panel intervalPanel;
  156.     java.awt.Label intervalLabel;
  157.     symantec.itools.awt.NumericSpinner intervalSpinner;
  158.     java.awt.Panel directionPanel;
  159.     java.awt.Label leftLabel;
  160.     symantec.itools.awt.DirectionButton leftButton;
  161.     symantec.itools.awt.DirectionButton rightButton;
  162.     java.awt.Label rightLabel;
  163.     //}}
  164.     
  165.     // Add the ScrollText manually.  In the future, make this a user component and add
  166.     // it to the component library
  167.     ScrollText scrollText;
  168. }
  169.