SlideShare a Scribd company logo
1 of 7
UNIQUE COMPUTER


AWT- Close
import java.awt.*;
import java.awt.event.*;
public class awt_close
{
  public static void main(String[] args)
{
  Frame frame = new Frame("Close Operation Frame");
  Label lbl = new Label("Welcome to Unique Computer: ",Label.CENTER);
  frame.add(lbl);
  frame.setSize(400,400);
  frame.setVisible(true);
  frame.addWindowListener(new WindowAdapter()
         {
                  public void windowClosing(WindowEvent we)
                  {
                          System.exit(0);
                  }
         }
         );
  }
}


Data-1

import java.awt.*;
import java.awt.event.*;
class data extends Frame implements ActionListener
{
        TextField txt=new TextField(20);
        TextField txt2=new TextField(20);
        Label lbl=new Label("Name",Label.LEFT);
        Label lbl2=new Label("Output");
        Button input_b=new Button("Input");
        Button exit_b=new Button("Exit");
        public data(String title)
        {
                 super(title);
                 setLayout(new FlowLayout());
                 add(lbl);
                 add(txt);
                 add(lbl2);
                 txt2.setEditable(false);
                 add(txt2);
                 add(input_b);
                 input_b.setBackground(Color.yellow);
                 input_b.setForeground(Color.red);
UNIQUE COMPUTER


                 add(exit_b);
                 input_b.addActionListener(this);
                 exit_b.addActionListener(this);


          }
          public void actionPerformed(ActionEvent e)
          {
                   if(e.getSource()==input_b)
                   {
                            String a=txt.getText();
                            txt2.setText(a);
                   }
                   if(e.getSource()==exit_b)
                   {
                            System.exit(0);
                   }
          }
          public static void main(String args[])
          {
                   data t=new data("Testing Component");
                   t.setSize(250,250);
                   t.show();
          }
}


Data- 2

import java.awt.*;
import java.awt.event.*;
class data_2 extends Frame implements ActionListener
{
        TextField txt=new TextField(20);
        TextField txt2=new TextField(20);
        Label lbl=new Label("Name",Label.LEFT);
        Label lbl2=new Label("Output");
        Button input_b=new Button("Input");
        Button exit_b=new Button("Exit");
        public data_2(String title)
        {
                 super(title);
                 setLayout(new FlowLayout());
                 add(lbl);
                 add(txt);
                 add(lbl2);
                 txt2.setEditable(false);
                 add(txt2);
UNIQUE COMPUTER


               add(input_b);
               input_b.setBackground(Color.yellow);
               input_b.setForeground(Color.red);
               add(exit_b);
               input_b.addActionListener(this);
               exit_b.addActionListener(this);


       }
       public void actionPerformed(ActionEvent e)
       {
                if(e.getSource()==input_b)
                {
                         int num=Integer.parseInt(txt.getText());
                         int sq=num*num;
                         txt2.setText(String.valueOf(sq));
                }
                if(e.getSource()==exit_b)
                {
                         System.exit(0);
                }
       }
       public static void main(String args[])
       {
                data_2 t=new data_2("Testing Component");
                t.setSize(250,250);
                t.show();
       }
}




Frame Demo

import java.awt.*;
class framedemo extends Frame
{
         public framedemo(String title)
         {
                  super(title);
         }
         public static void main(String args[])
         {
                  framedemo obj=new framedemo("I have been Frame");
                  obj.setSize(500,500);
                  obj.setVisible(true);
         }
}
UNIQUE COMPUTER


Panel

import java.awt.*;
class paneldemo extends Panel
{
        public paneldemo()
        {

        }
        public static void main(String args[])
        {
                 paneldemo obj=new paneldemo();
                 Frame f=new Frame("Testing a Panel");
                 f.add(obj);
                 f.setSize(500,500);
                 f.setVisible(true);

        }
}


Label

import java.awt.*;
import java.awt.event.*;
class t_label extends Frame implements ActionListener
{
         TextField txt=new TextField(20);
         Label lbl=new Label("Name");
         Button exit_b=new Button("Exit");
         public t_label(String title)
         {
                  super(title);
                  setLayout(new FlowLayout());
                  add(lbl);
                  add(txt);
                  System.out.println();
                  add(exit_b);
                  exit_b.addActionListener(this);


        }
        public void actionPerformed(ActionEvent e)
        {
                if(e.getSource()==exit_b)
                {
                         System.exit(0);
                }
UNIQUE COMPUTER


       }
       public static void main(String args[])
       {
                t_label t=new t_label("Testing Component");
                t.setSize(250,250);
                t.show();
       }
}



                                             APPLET
Applet-Life Cycle:

import java.awt.*;
import java.applet.*;

public class applet_demo1 extends Applet
{
        public void init()
        {
                setBackground(Color.cyan);
                setForeground(Color.red);
        }
        public void start()
        {

       }
       public void stop()
       {

       }
       public void destroy()
       {
       }
       public void paint(Graphics g)
       {

       }
}
UNIQUE COMPUTER


Applet-String 1:

import java.awt.*;
import java.applet.*;
/*
<applet code="applet_demo2" width=300 height=100>
</applet>
*/
public class applet_demo2 extends Applet
{
        String msg;
        public void init()
        {
        setBackground(Color.cyan);
        setForeground(Color.red);
        msg="Inside init()";
        }
        public void start()
        {
        msg+=" Inside_Start()";
        }
        public void stop()
        {
        }
        public void destroy()
        {
        }
        public void paint(Graphics g)
        {
        msg+=" Inside_Paint()";
        g.drawString(msg,40,40);
        }
}


Applet String- Scrolling:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
/*
<applet code="applet_demo3" width=300 height=100>
</applet>
*/
UNIQUE COMPUTER


public class applet_demo3 extends Applet implements Runnable
{
        String msg;
        Thread t=null;
        char c;
        public void init()
        {
        setBackground(Color.cyan);
        setForeground(Color.red);
        msg=" A simple banner ";
        }
        public void start()
        {
                try
                {
                  t=new Thread(this);
                  t.start();
                }catch(Exception e){}
        }
        public void stop()
        {
        }
        public void destroy()
        {
        }
        public void paint(Graphics g)
        {
                g.drawString(msg,50,50);
        }
        public void run()
        {
                for(;;)
                {
                  try
                  {
                         repaint();
                         t.sleep(300);
                         c=msg.charAt(0);
                         msg=msg.substring(1,msg.length());
                         msg=msg+c;
                  }catch(Exception e){}
                 }
        }
}

More Related Content

What's hot

Java simple programs
Java simple programsJava simple programs
Java simple programs
VEERA RAGAVAN
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
Soumya Behera
 

What's hot (19)

Java simple programs
Java simple programsJava simple programs
Java simple programs
 
Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1
 
The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185The Ring programming language version 1.5.4 book - Part 33 of 185
The Ring programming language version 1.5.4 book - Part 33 of 185
 
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31
 
The Ring programming language version 1.5.1 book - Part 31 of 180
The Ring programming language version 1.5.1 book - Part 31 of 180The Ring programming language version 1.5.1 book - Part 31 of 180
The Ring programming language version 1.5.1 book - Part 31 of 180
 
The Ring programming language version 1.9 book - Part 40 of 210
The Ring programming language version 1.9 book - Part 40 of 210The Ring programming language version 1.9 book - Part 40 of 210
The Ring programming language version 1.9 book - Part 40 of 210
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
Java file
Java fileJava file
Java file
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
The Ring programming language version 1.5.3 book - Part 10 of 184
The Ring programming language version 1.5.3 book - Part 10 of 184The Ring programming language version 1.5.3 book - Part 10 of 184
The Ring programming language version 1.5.3 book - Part 10 of 184
 
Javascript
JavascriptJavascript
Javascript
 
The Ring programming language version 1.4 book - Part 9 of 30
The Ring programming language version 1.4 book - Part 9 of 30The Ring programming language version 1.4 book - Part 9 of 30
The Ring programming language version 1.4 book - Part 9 of 30
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка
 
The Ring programming language version 1.3 book - Part 23 of 88
The Ring programming language version 1.3 book - Part 23 of 88The Ring programming language version 1.3 book - Part 23 of 88
The Ring programming language version 1.3 book - Part 23 of 88
 
Java File
Java FileJava File
Java File
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
 
The Ring programming language version 1.10 book - Part 101 of 212
The Ring programming language version 1.10 book - Part 101 of 212The Ring programming language version 1.10 book - Part 101 of 212
The Ring programming language version 1.10 book - Part 101 of 212
 

Similar to Awt

Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
Technopark
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
MaruMengesha
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
archanaemporium
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
akkhan101
 

Similar to Awt (20)

Java programs
Java programsJava programs
Java programs
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Java oops features
Java oops featuresJava oops features
Java oops features
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
TDD Hands-on
TDD Hands-onTDD Hands-on
TDD Hands-on
 
662305 11
662305 11662305 11
662305 11
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdf
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
JDK 8
JDK 8JDK 8
JDK 8
 
Awt components
Awt componentsAwt components
Awt components
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Nabil code
Nabil  codeNabil  code
Nabil code
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Awt

  • 1. UNIQUE COMPUTER AWT- Close import java.awt.*; import java.awt.event.*; public class awt_close { public static void main(String[] args) { Frame frame = new Frame("Close Operation Frame"); Label lbl = new Label("Welcome to Unique Computer: ",Label.CENTER); frame.add(lbl); frame.setSize(400,400); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } } ); } } Data-1 import java.awt.*; import java.awt.event.*; class data extends Frame implements ActionListener { TextField txt=new TextField(20); TextField txt2=new TextField(20); Label lbl=new Label("Name",Label.LEFT); Label lbl2=new Label("Output"); Button input_b=new Button("Input"); Button exit_b=new Button("Exit"); public data(String title) { super(title); setLayout(new FlowLayout()); add(lbl); add(txt); add(lbl2); txt2.setEditable(false); add(txt2); add(input_b); input_b.setBackground(Color.yellow); input_b.setForeground(Color.red);
  • 2. UNIQUE COMPUTER add(exit_b); input_b.addActionListener(this); exit_b.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==input_b) { String a=txt.getText(); txt2.setText(a); } if(e.getSource()==exit_b) { System.exit(0); } } public static void main(String args[]) { data t=new data("Testing Component"); t.setSize(250,250); t.show(); } } Data- 2 import java.awt.*; import java.awt.event.*; class data_2 extends Frame implements ActionListener { TextField txt=new TextField(20); TextField txt2=new TextField(20); Label lbl=new Label("Name",Label.LEFT); Label lbl2=new Label("Output"); Button input_b=new Button("Input"); Button exit_b=new Button("Exit"); public data_2(String title) { super(title); setLayout(new FlowLayout()); add(lbl); add(txt); add(lbl2); txt2.setEditable(false); add(txt2);
  • 3. UNIQUE COMPUTER add(input_b); input_b.setBackground(Color.yellow); input_b.setForeground(Color.red); add(exit_b); input_b.addActionListener(this); exit_b.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==input_b) { int num=Integer.parseInt(txt.getText()); int sq=num*num; txt2.setText(String.valueOf(sq)); } if(e.getSource()==exit_b) { System.exit(0); } } public static void main(String args[]) { data_2 t=new data_2("Testing Component"); t.setSize(250,250); t.show(); } } Frame Demo import java.awt.*; class framedemo extends Frame { public framedemo(String title) { super(title); } public static void main(String args[]) { framedemo obj=new framedemo("I have been Frame"); obj.setSize(500,500); obj.setVisible(true); } }
  • 4. UNIQUE COMPUTER Panel import java.awt.*; class paneldemo extends Panel { public paneldemo() { } public static void main(String args[]) { paneldemo obj=new paneldemo(); Frame f=new Frame("Testing a Panel"); f.add(obj); f.setSize(500,500); f.setVisible(true); } } Label import java.awt.*; import java.awt.event.*; class t_label extends Frame implements ActionListener { TextField txt=new TextField(20); Label lbl=new Label("Name"); Button exit_b=new Button("Exit"); public t_label(String title) { super(title); setLayout(new FlowLayout()); add(lbl); add(txt); System.out.println(); add(exit_b); exit_b.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==exit_b) { System.exit(0); }
  • 5. UNIQUE COMPUTER } public static void main(String args[]) { t_label t=new t_label("Testing Component"); t.setSize(250,250); t.show(); } } APPLET Applet-Life Cycle: import java.awt.*; import java.applet.*; public class applet_demo1 extends Applet { public void init() { setBackground(Color.cyan); setForeground(Color.red); } public void start() { } public void stop() { } public void destroy() { } public void paint(Graphics g) { } }
  • 6. UNIQUE COMPUTER Applet-String 1: import java.awt.*; import java.applet.*; /* <applet code="applet_demo2" width=300 height=100> </applet> */ public class applet_demo2 extends Applet { String msg; public void init() { setBackground(Color.cyan); setForeground(Color.red); msg="Inside init()"; } public void start() { msg+=" Inside_Start()"; } public void stop() { } public void destroy() { } public void paint(Graphics g) { msg+=" Inside_Paint()"; g.drawString(msg,40,40); } } Applet String- Scrolling: import java.awt.*; import java.applet.*; import java.awt.event.*; import java.util.*; /* <applet code="applet_demo3" width=300 height=100> </applet> */
  • 7. UNIQUE COMPUTER public class applet_demo3 extends Applet implements Runnable { String msg; Thread t=null; char c; public void init() { setBackground(Color.cyan); setForeground(Color.red); msg=" A simple banner "; } public void start() { try { t=new Thread(this); t.start(); }catch(Exception e){} } public void stop() { } public void destroy() { } public void paint(Graphics g) { g.drawString(msg,50,50); } public void run() { for(;;) { try { repaint(); t.sleep(300); c=msg.charAt(0); msg=msg.substring(1,msg.length()); msg=msg+c; }catch(Exception e){} } } }