Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners regarding applets
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tushar087
regarding applets
1 Answer(s)      6 years and a month ago
Posted in : Java Beginners



Advertisement
View Answers

September 16, 2008 at 4:38 PM


Hi friend,


import java.awt.*;
import java.awt.Dimension;

public class GridCanvas extends Canvas {
private final int NumLines = 10;
private String greeting = "Greetings!";

public GridCanvas(int width, int height) {

resize(width, height);

}
public void paint(Graphics g) {
Dimension dim = size();
g.drawRect(1, 1, dim.width-2, dim.height-2);
for (int i = 0; i < NumLines; i++) {
int x = (int)((double)(i * (dim.width - 1))/(NumLines-1));
g.drawLine(x, 0, x, dim.height-1);
}
g.drawString(greeting, 12, 12);
}
public void setGreeting(String newGreeting) {
greeting = newGreeting;
repaint();

}
}

---------------------------------------------

import java.awt.*;
import java.awt.Dimension;
import java.applet.Applet;

public class AppletImp extends Applet {

private TextField textField = null;
private GridCanvas gridCanvas = null;
private TextArea debugArea = null;

public void DisplayText(String string) {
debugArea.appendText(string);
}
static final String textbutton = "Click Me";
public void init() {
Button button = new Button(textbutton);
add(button);
textField = new TextField("", 20);
add(textField);
gridCanvas = new GridCanvas(100, 100);
add(gridCanvas);
debugArea = new TextArea(5, 25);
add(debugArea);
}
public boolean action(Event event, Object arg) {
DisplayText("Action...\n");
if(arg.equals(textbutton)) {
String newText = textField.getText();
DisplayText("Welcome Roseindia ");
gridCanvas.setGreeting(newText);
}
else return(false);
return(true);
}
};

----------------------
<HTML>
<BODY>
<div align = "center">
<APPLET CODE = "AppletImp.class" WIDTH = "500" HEIGHT = "300"></APPLET>
</div>
</BODY>
</HTML>

------------------------------------------

Visit for more information.

http://www.roseindia.net/java/example/java/awt/

Thanks.
Amardeep


Related Tutorials/Questions & Answers:
regarding applets - Java Beginners
regarding applets  sir can you please tell how one applet can send request to another say i want to send some information   Hi friend, import java.awt.*; import java.awt.Dimension; public class GridCanvas
Applets?
Applets?  applets are using now a days   Please visit the following link: Applet Tutorials
Advertisements
APPLETS - Security
APPLETS  In java applets sun.misc is not working can any body help me for the alternate solution. while using new sun.misc.BASE64Encoder().encode(enc); i got runtime error... java.security.AccessControlException
Applications and Applets
Applications and Applets       Now a days, Java is widely used for applications and applets. The code... the user's browser. Applets can be very useful, user friendly programs or can
Applications and Applets
Applications and Applets       Now a days, Java is widely used for applications and applets. The code... the user's browser. Applets can be very useful, user friendly programs or can
Regarding repository
Regarding repository  How to check in and check out using SVN repository using eclipse
regarding rev
regarding rev  write a prog. in java that display all the arguments passed at the command line in reverse order
Servlet v/s Applets - Servlet Interview Questions
Servlet v/s Applets  what is difference between servlets & applets
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Hibernate
Regarding Hibernate  Both JDBC and Hibernate are used to connect to database then whats the need of going to hibernate? What are the main differences? And could you let me know please
Programming using applets and oracle - Applet
Programming using applets and oracle  Develop an Online Examination software in java using applets as front end and oracle as back end. Software should handle at least ten users at a time. There are Multiple Choice questions
Applets in Java
Applet is a Java program embedded within HTML pages. Java applets is compatible with almost all the web browsers like Mozilla Firefox, Google Chrome, Internet explorer, Netscape navigator and others that are java enabled. Applets
Free Java Applets
Free Java Applets       There are many free java applets available on the web that you can use in your website. These applets includes menu, clock, slide show, image animation
Regarding javascript
Regarding javascript  Hi, I want 4 upload buttons in HTML CODE and Among 4 browse buttons user is not selected any one then provide a prompt message like plz select any 1 file among 4 buttons.If user is selected either 1st
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container below that row itself and show the required details of the row
Regarding Datasource
Regarding Datasource  Hi friend, Good morning,how r u,i want to share 1 information to u,I got a job in VERIZON DATA SERVICES INDIA PVT.LTD,u help a lot when i am in academic project,with that project only i got a job
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get the relevant
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get
regarding project
regarding project   sir we need help about project. we have idea about his project please guide me sir. OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
regarding jdbc - JDBC
regarding jdbc  how i can configure java with ms access
Regarding weblogic portal
Regarding weblogic portal  Hi, My name is Ramanuja.i am working on weblogic portal.if u know any info regarding plz provide the materials or information to me.plz help me. Thanks in advance
Regarding project - Applet
Regarding project  hi friend , iam doing project in Visual cryptography in Java so i need the Help regarding how to make a share of a original imahe into shares anu
Regarding core java
Regarding core java  how do we find reverse of string with out using String functions
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application
regarding struts 2
regarding struts 2   is it not possible to get values from applicationresources.properties into our application in struts 2
Advertisements
 

 

 

DMCA.com