Skip to main content

Posts

Html Practical

<html> <head> <title> blog </title> <!--Title is used to identify the contents of a document.It defines a title in the browser--> <base href="http://solvedprograms.blogspot.in" target="_self"> <!-- Base specifies a default url & a default target for all links on a page --> <meta name="keywords" content="html,xml"> <!--The meta element specifies a property and assign a value to it.Mainly used for seo--> <link rel="stylesheet" type="text/css" href="a.css"/> <!--It is used to link other documents to the webpage--> <style type="text\css"> H1{font-size:72px} </style> <!--IT is used to set style of a document--> <script language="javascript"> </script> </head> <body background="" bgcolor="gray" leftmargin="100" topmargin="100...

Java Applet program to draw and move rectangle

import java.applet.Applet; import java.awt.*; import java.math.*; /*<applet code="pro" height=100 width=100></applet>   */ public class pro extends Applet implements Runnable { Thread t; public void init() { t=new Thread(this); t.start(); } public void run() { try { while(true) { repaint(); t.sleep(1000); } }catch(Exception e) { System.out.println(e); } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { Dimension d=this.getSize(); g.setColor(Color.black); g.fillRect(0,0,d.width,d.height); double x=Math.random()*d.width; double y=Math.random()*d.height; g.setColor(Color.blue); g.fillRect((int)x,(int)y,50,50); } }

Applet program to display random rectangle drawing on screen

import java.applet.Applet; import java.awt.*; import java.math.*; /*<applet code="pro" height=100 width=100></applet>   */ public class pro extends Applet implements Runnable { Thread t; public void init() { t=new Thread(this); t.start(); } public void run() { try { while(true) { repaint(); t.sleep(1000); } }catch(Exception e) { System.out.println(e); } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { setBackground(Color.black); Dimension d=this.getSize(); double x=Math.random()*d.width; double y=Math.random()*d.height; setForeground(Color.blue); g.fillRect((int)x,(int)y,50,50); } }

List and Textfield of java.awt class

SOURCE & COPIED FROM: http://www.tutorialspoint.com/awt/awt_quick_guide.htm AWT List Class Introduction The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items. Class declaration Following is the declaration for  java.awt.List  class: public class List extends Component implements ItemSelectable , Accessible Class constructors S.N. Constructor & Description 1 List()  Creates a new scrolling list. 2 List(int rows)  Creates a new scrolling list initialized with the specified number of visible lines. 3 List(int rows, boolean multipleMode)  Creates a new scrolling list initialized to display the specified number of rows. Class methods <T extends EventListener> T[] getListeners(Class<T> listenerType)  Returns an array of all the objects currently registered as FooListeners upon this List. S.N. Method & Description 1 vo...