home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-12-13 | 5.6 KB | 169 lines |
- /*
- A basic extension of the java.applet.Applet class
- */
-
- import java.awt.*;
- import java.applet.*;
-
- public class ScrollTextSample extends Applet {
- void rightButton_Action(Event event) {
- // to do: place event handler code here.
- if (scrollText != null)
- scrollText.setScrollDirection(ScrollText.SCROLL_RIGHT);
- }
-
- void leftButton_Action(Event event) {
- // to do: place event handler code here.
- if (scrollText != null)
- scrollText.setScrollDirection(ScrollText.SCROLL_LEFT);
- }
-
- void intervalSpinner_Action(Event event) {
- // to do: place event handler code here.
- if (scrollText != null)
- scrollText.setScrollInterval(intervalSpinner.getCurrent());
- }
-
- void unitSlider_Action(Event event) {
- // to do: place event handler code here.
- if (scrollText != null)
- scrollText.setScrollUnit(unitSlider.getValue());
- }
-
- void textText_EnterHit(Event event) {
- // to do: place event handler code here.
- if (scrollText != null)
- scrollText.setText(textText.getText());
- }
-
-
- 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));
- addNotify();
- resize(319,265);
- setBackground(new Color(12632256));
- panel1 = new java.awt.Panel();
- panel1.setLayout(new GridLayout(4,1,5,5));
- panel1.reshape(0,0,319,265);
- add("Center", panel1);
- textPanel = new java.awt.Panel();
- textPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
- textPanel.reshape(0,0,319,62);
- panel1.add(textPanel);
- textlabel = new java.awt.Label("Scroll Text");
- textlabel.reshape(34,5,75,21);
- textPanel.add(textlabel);
- textText = new java.awt.TextField();
- textText.setText("Visual Cafe from Symantec");
- textText.reshape(114,5,171,21);
- textPanel.add(textText);
- unitPanel = new java.awt.Panel();
- unitPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
- unitPanel.reshape(0,67,319,62);
- panel1.add(unitPanel);
- unitLabel = new java.awt.Label("Scroll Unit ");
- unitLabel.reshape(76,17,81,21);
- unitPanel.add(unitLabel);
- unitSlider = new symantec.itools.awt.HorizontalSlider();
- unitSlider.reshape(162,5,80,45);
- unitSlider.setBackground(new Color(16777215));
- unitPanel.add(unitSlider);
- unitSlider.setMinValue(5);
- unitSlider.setMaxValue(30);
- unitSlider.setTickFreq(5);
- unitSlider.setValue(10);
- unitSlider.setTickStyle(symantec.itools.awt.HorizontalSlider.TICK_TOP);
- intervalPanel = new java.awt.Panel();
- intervalPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
- intervalPanel.reshape(0,134,319,62);
- panel1.add(intervalPanel);
- intervalLabel = new java.awt.Label("Scroll Interval");
- intervalLabel.reshape(71,10,93,21);
- intervalPanel.add(intervalLabel);
- intervalSpinner = new symantec.itools.awt.NumericSpinner();
- intervalSpinner.reshape(169,5,79,32);
- intervalPanel.add(intervalSpinner);
- intervalSpinner.setMin(50);
- intervalSpinner.setMax(300);
- intervalSpinner.setCurrent(150);
- intervalSpinner.setIncrement(10);
- directionPanel = new java.awt.Panel();
- directionPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
- directionPanel.reshape(0,201,319,62);
- panel1.add(directionPanel);
- leftLabel = new java.awt.Label("Scroll left ");
- leftLabel.reshape(52,5,80,21);
- directionPanel.add(leftLabel);
- leftButton = new symantec.itools.awt.DirectionButton();
- leftButton.reshape(137,5,20,20);
- directionPanel.add(leftButton);
- rightButton = new symantec.itools.awt.DirectionButton();
- rightButton.reshape(162,5,20,20);
- directionPanel.add(rightButton);
- rightButton.setDirection(symantec.itools.awt.DirectionButton.RIGHT);
- rightLabel = new java.awt.Label("Scroll Right");
- rightLabel.reshape(187,5,80,21);
- directionPanel.add(rightLabel);
- //}}
-
- // Create the ScrollText at the bottom of the applet
- // Also change the font so it is more noticable
- scrollText = new ScrollText();
- scrollText.reshape(0,100,200,50);
- scrollText.setFont(new Font("Dialog", Font.BOLD, 16));
- add("South", scrollText);
- }
-
- public boolean handleEvent(Event event) {
- if (event.target == textText && event.id == Event.ACTION_EVENT) {
- textText_EnterHit(event);
- return true;
- }
- if (event.target == unitSlider && event.id == Event.ACTION_EVENT) {
- unitSlider_Action(event);
- return true;
- }
- if (event.target == intervalSpinner && event.id == Event.ACTION_EVENT) {
- intervalSpinner_Action(event);
- return true;
- }
- if (event.target == leftButton && event.id == Event.ACTION_EVENT) {
- leftButton_Action(event);
- return true;
- }
- if (event.target == rightButton && event.id == Event.ACTION_EVENT) {
- rightButton_Action(event);
- return true;
- }
- return super.handleEvent(event);
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Panel panel1;
- java.awt.Panel textPanel;
- java.awt.Label textlabel;
- java.awt.TextField textText;
- java.awt.Panel unitPanel;
- java.awt.Label unitLabel;
- symantec.itools.awt.HorizontalSlider unitSlider;
- java.awt.Panel intervalPanel;
- java.awt.Label intervalLabel;
- symantec.itools.awt.NumericSpinner intervalSpinner;
- java.awt.Panel directionPanel;
- java.awt.Label leftLabel;
- symantec.itools.awt.DirectionButton leftButton;
- symantec.itools.awt.DirectionButton rightButton;
- java.awt.Label rightLabel;
- //}}
-
- // Add the ScrollText manually. In the future, make this a user component and add
- // it to the component library
- ScrollText scrollText;
- }
-