# drawing shapes in applet

May 31, 2008 at 4:50 PM

Hi manju,

This is cube example

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

public class CubeExample extends Applet {
Stroke drawingStroke = new BasicStroke(4);
CubicCurve2D cubic= new CubicCurve2D.Double(40,150, 40, 05, 300, 350, 300, 180);

public void paint (Graphics g){
Graphics2D ga = (Graphics2D)g;
g.setColor (Color.green);
ga.setStroke(drawingStroke);
ga.draw(cubic);

}
}

<HTML>
<BODY>
<div align = "center">
<APPLET CODE = "CubeExample.class" WIDTH = "500" HEIGHT = "400"></APPLET>
</div>
</BODY>
</HTML>

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

Square in circle

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

public class CircleExample extends Applet {

public void paint (Graphics g){
Graphics2D ga = (Graphics2D)g;
Shape square = new Rectangle2D.Double(100, 100,50, 50);
g.setColor (Color.red);
g.fillOval (100,100,50,50);
ga.draw(square);

}
}

<HTML>
<BODY>
<div align = "center">
<APPLET CODE = "CircleExample.class" WIDTH = "500" HEIGHT = "400"></APPLET>
</div>
</BODY>
</HTML>

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

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

Related Tutorials/Questions & Answers:
drawing shapes in applet - Applet
drawing shapes in applet  hi, i need a single applet prgm which... java.applet.Applet; public class CubeExample extends Applet { Stroke... Applet { public void paint (Graphics g){ Graphics2D ga = (Graphics2D)g
An Applet program for Drawing picture & graph - Applet
An Applet program for Drawing picture & graph  How can I write an Applet program for drawing picture and graph having various colours and tools provided
Write a Java applet to draw cylinder and pentagon shapes.
Write a Java applet to draw cylinder and pentagon shapes.  Write a Java applet to draw cylinder and pentagon shapes
Applet program for drawing picture and graph - Applet
Applet program for drawing picture and graph  Please send me the program(code) of drawing picture and graph in Applet.  Hi Friend.../applet/ http://www.roseindia.net/tutorial/java/swing/createHumanFace.html Hope
Java - Drawing Shapes Example in java
Java - Drawing Shapes Example in java       Introduction Applet is a program to run... but it is a network level program. The Applet class is a super class
Java - Drawing Shapes Example using color in java
Java - Drawing Shapes Example using color in java  ... will show you how to draw the different types of colorful shapes. This example show the different types of colorful shapes like line, circle and the rectangle. It also
display shapes
display shapes  Hi, I would like to see geometric shapes like square, triangle, circle, rectangle as my outputs. Also, those figures shouldn't overlap while they get displayed. Please help me
Applet
Applet  Write an applet to display a string in an applet. String should be passed as a parameter to an applet
Applet
Applet  how to run an applet on a web browser
Applet
Applet  Give the class hierarchy of an Applet class
applet
applet  What is the immediate superclass of the Applet class
applet
applet  Explain different stages in the lifecycle of an applet with figure.   Stages of Applet: Life cycle of an Applet: init(): This method is called to initialized an applet start(): This method is called after
What is Applet in Java with Example?
Drawing Shapes Drawing Shapes using color Event Listeners Passing Parameters... What is Applet in Java with Examples? In this section we are going to learn the Applet in Java. In Java Applet are special Java program
Applet
Applet  Write a ava applet that sets blue color foreground and yellow color background at the start of an applet
Applet
Applet  Explain the start() and stop() methods of applet life cycle.   Start and Start method of Applet Life Cycle Start () method: The start method of an applet is called after the initialization method init
Applet
Applet  Write a short note on applet life cycle
Applet
Applet  I have a java applet that has a button. On clicking the button it should disappear and another applet should appear. How to write this code???? Also in login applet after successful login it should display admin applet
Applet
Applet  Draw the class hierarchy of an Applet class. Also explain how to set background and forground colors in java
applet
applet  what is applet in java   An applet is a small program that can be sent along with a Web page to a user. Java applets can perform... the following link: Applet Tutorials
Applet
Applet  Write a Java applet that drwas a line between 2 points. The co-ordinates of 2 points should be passed as parametrs from html file. The color of the line should be red
applet
applet  applet to open new tab not working.here's my code import java.applet.*; import java.awt.*; import java.net.*; import java.awt.event.*; public class NewURL extends Applet implements ActionListener{ public void init
ModuleNotFoundError: No module named 'shapes'
ModuleNotFoundError: No module named 'shapes'  Hi, My Python... 'shapes' How to remove the ModuleNotFoundError: No module named 'shapes'... to install padas library. You can install shapes python with following command
java program of different shapes
java program of different shapes  pls help me to get the code of a java program of different shapes using menu
applet printing
applet printing  i am making a frame in which i am calling three applets gridwise and in each applet i am drawing some graph so while printing whole frame i am able to print all 3 applets together on one page but in each applet i
applet - Applet
.  Hi Friend, Try the following code: 1)Create an applet... extends Applet{ public void paint(Graphics g){ g.drawString("Welcome in Java Applet.",40,20); } } 2) Call this applet with html code
Java code - Applet
Java code  I want java applet code for drawing an indian flag
What is Applet? - Applet
What is Applet?  What is Applet?  Hi,Here is a little information about Applet.An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were
Applet - Applet
Applet  what is the concept of applet? what is different between the applet concept and HTML? what is mean by swing?  Hi friend, Applet Applet is java program that can be embedded into HTML pages. Java applets
ModuleNotFoundError: No module named 'drawing'
ModuleNotFoundError: No module named 'drawing'  Hi, My Python... 'drawing' How to remove the ModuleNotFoundError: No module named 'drawing... to install padas library. You can install drawing python with following command
Java Shapes Bouncing App
Java Shapes Bouncing App  hi guys, im trying to implement... JApplet and contains a panel where * shapes move around on the screen. Also... main(String[] args) { A1 applet = new A1(); JFrame frame = new
How many types of drawing objects are available in drawing toolbar
How many types of drawing objects are available in drawing toolbar  How many types of drawing objects are available in drawing toolbar
applet - Applet
*; import java.awt.*; public class CreateTextBox extends Applet implements.../applet/ Thanks
ModuleNotFoundError: No module named 'django-shapes'
ModuleNotFoundError: No module named 'django-shapes'  Hi, My... 'django-shapes' How to remove the ModuleNotFoundError: No module named 'django-shapes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-shapes'
ModuleNotFoundError: No module named 'django-shapes'  Hi, My... 'django-shapes' How to remove the ModuleNotFoundError: No module named 'django-shapes' error? Thanks   Hi, In your python
Applet - Applet
Applet   Namaste, I want to create a Menu, the menu name is "Display... java.awt.event.*; public class menu2frame extends Applet implements WindowListener...------------------------"); g.drawString("Demo of Java Applet Window Event Program"); g.drawString("Java
Drawing Graphs - Swing AWT
Drawing Graphs  hi i am doing a small project in java swings . there is a database table having two columns A,B i want to plot a graph to that values in database the graph must be interactive graph
Drawing with Color in Java
(), fillOval() and other for drawing various shapes on the screen. You can use...Drawing with Color in Java       ... how to draw colorful shapes in java swing. There are various colorful shapes
Drawing Graphs - Java3D
Drawing Graphs  how to draw graphs using certain parameters  Hi Friend, To draw a graph using JfreeChart library, please visit the following link: http://www.roseindia.net/chartgraphs/index.shtml Here you
scrolling a drawing..... - Swing AWT
scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas is dynamic and hence there is no fixed size, that's why i need to make
Applet Error - Applet
Applet Error  Hi... I had an application where i designed an applet to get the database values into the applet when i clicked a line... It works... Applet implements MouseListener{ boolean
Applet to database error - Applet
Applet to database error  Hi... I had an application where i need to connect to the database for the values to display in the applet.... Following... Applet implements MouseListener{ boolean rect1Clicked,rect1Clicked1,mouseEntered
drawing out of bounds
drawing out of bounds  How to throw an exception when a rectangle goes out of the boundaries of a JFrame. The program is asking to draw a triangle, and resize it. If the triagle size goes out of the JFrame throw an execption. I
applet problem - Applet
applet problem  How can I create a file in client side by a java applet . Surely it will need a signed applet .But how can a signed applet create a file in the client side
How to convert a picture to drawing, convert a picture to drawing, picture to drawing
How to convert a picture to drawing       Learn here a simple processing to make a color picture to drawing, we have tried here to take simple step to learn easily for the beginners