Skip to main content

creating simple graphics appletviewer java


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

//<applet code="Appletdemo" height=500 width=500></applet>

public class Appletdemo extends Applet implements ActionListener
{

            String s;
            Button b1,b2;

            public void init()
            {
                        b1= new Button("Test");
                        b2=new Button("circle");
                        add(b1);
                        add(b2);
                        b1.addActionListener(this);
                        b2.addActionListener(this);
            }

            public void actionPerformed(ActionEvent ae)
            {
                        s=ae.getActionCommand();
                        repaint();
            }

            public void paint(Graphics g)
            {
                        try
                        {
                        if(s.equals("Test"));
                        g.drawOval(122,53,62,75);
                        //g.setColor(212, 23,45);

                        if(s.equals("circle"));
                        g.drawRect(122,122,122,122);

                        }
                        catch(NullPointerException e)
                        {}
            }
}

Comments

Popular posts from this blog

FACTORIAL OF A NUMBER USING RMI IN JAVA

CLIENT PROGRAM: import java.io.*; import java.rmi.*; public class client { public static void main(String args[])throws Exception { try { String s="rmi://"+args[0]+"/abc"; serverint f=(serverint)Naming.lookup(s); DataInputStream m=new DataInputStream(System.in); int n1=Integer.parseInt(m.readLine()); System.out.println("the factorial is"+f.fact(n1)); } catch(Exception e) { System.out.println(e); } } } INTERFACE PROGRAM: import java.rmi.*; public interface serverint extends Remote { int fact(int n)throws Exception; } IMPLEMENTATION PROGRAM: import java.rmi.*; import java.rmi.server.*; public class serverimpl extends UnicastRemoteObject implements serverint { public serverimpl()throws Exception { } public int fact(int n) { int i,c=1; for(i=1;i<=n;i++) { c=i*c; } ret...

CREATE A PYRAMID PROGRAM IN C

#include<stdio.h> #include<conio.h> void main() {    int row, c, n, temp;    printf("Enter the number of rows in pyramid of stars you wish to see ");    scanf("%d",&n);    temp = n;     for ( row = 1 ; row <= n ; row++ )    {       for ( c = 1 ; c < temp ; c++ )          printf(" ");        temp--;        for ( c = 1 ; c <= 2*row - 1 ; c++ )          printf("$");        printf("\n");    }  getch(); } OUTPUT: Enter the number of rows in pyramid of stars you wish to see: 5 $ $$$ $$$$$ $$$$$$$ $$$$$$$$$
Write a c program or code to subtract two numbers without using subtraction operator #include <stdio.h> int main(){         int a,b;     int sum;     printf( "Enter any two integers: " );     scanf( "%d%d" ,&a,&b);     sum = a + ~b + 1;     printf( "Difference of two integers: %d" ,sum);     return 0; } Sample Output: Enter any two integers: 5 4 Difference of two integers: 1