Share on Google+Share on Google+

Puneet
programs
4 Answer(s)      8 years ago
Posted in : Java Magazine

Ads

View Answers

September 21, 2008 at 7:48 PM



You clarify which techlogy we want?
Applet swing or java2d

use this other wise specify technologies


import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class DrawCircle extends Applet {

public void paint(Graphics g){
g.setColor(Color.red);
g.fillOval(50, 120, 50, 50);
}
}

Thanks
Rajanikant


September 21, 2008 at 8:21 PM


You can use this also

This program based on Java2D

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

import javax.swing.JApplet;
public class DrawCircle extends JApplet {
final static BasicStroke stroke = new BasicStroke(2.0f);
public void paint(Graphics g){
setBackground(Color.lightGray);
Graphics2D g2 = (Graphics2D)g;
g2.setPaint(Color.yellow);
g2.setStroke(stroke);
g2.fill(new Ellipse2D.Double(50,50,80,80));
}
}

Thanks
Rajanikant


September 22, 2008 at 11:39 AM


Hi,


import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class CircleTest extends JApplet
implements ActionListener {
JPanel InputPanel;
JLabel Tag;
JTextField field;
CircleCanvas Drawing;

public CircleTest() {
LayoutManager Layout;
Container Pane;

Layout = new FlowLayout ();
InputPanel = new JPanel ();
Tag = new JLabel ();
field = new JTextField ();
Drawing = new CircleCanvas ();
Pane = getContentPane ();

InputPanel.setLayout (Layout);
Tag.setText ("Diameter ");
Tag.setHorizontalAlignment (JLabel.RIGHT);
field.setColumns (8);
field.setText("10");
field.setHorizontalAlignment (JTextField.RIGHT);
field.addActionListener (this);
InputPanel.add(Tag);
InputPanel.add(field);
Pane.add (InputPanel, BorderLayout.NORTH);
Pane.add (Drawing, BorderLayout.CENTER);
}

public void actionPerformed (ActionEvent e) {
int Diameter;
String Text;

Text = field.getText();
Diameter = Integer.parseInt(Text);
Drawing.setDiameter(Diameter);
Drawing.repaint();
}
}

class CircleCanvas extends Canvas {
int Diameter;

public CircleCanvas () {
setBackground (Color.pink);
}

public void setDiameter(int Value) {
Diameter = Value;
repaint ();
}

public void paint (Graphics g) {
Graphics2D g2;
Ellipse2D Circle;
int Width;
int Height;
g2 = (Graphics2D) g;
g2.setColor (Color.red);
Width = getWidth ();
Height = getHeight ();
Circle = new Ellipse2D.Double
((double) ((Width - Diameter) / 2),
(double) ((Height - Diameter) / 2),
(double) Diameter, (double)Diameter);
g2.fill (Circle);
}

}


September 22, 2008 at 11:42 AM


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

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

Visit for more information :

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


Thanks

Amardeep









Related Tutorials/Questions & Answers:
programs
programs  give some programs on control statementds
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
Advertisements
php programs
php programs  10 programs on varibles
java programs
java programs  Why word "static" is used in java programs
Java Programs
Java Programs  Hi, What is Java Programs? How to develop application for business in Java technology? Is there any tool to help Java programmer in development of Java Programs? Thanks
php programs
php programs  I need 15 programs on arithmetic operators with comments. Please help me
java programs
java programs  Explain types of Java programs. Also explain how to compile and run them.   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
programs in java
programs in java  . I need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc.., pl z guide me how to write these programe
java programs
java programs  i need help in understanding the whole concept of the 13 java programs that i hav...here r de programs.. int i,j,m,n; m=Integer.parseInt(args [0]); n=Integer.parseInt(args [1]); System.out.print
c++ programs
c++ programs  i want the syntax for the following programs according to c++ pattern. 1.sum of multiples of an integer upto 10 2.2/4+4/6+6/8+8/10+.....n/n+2 3.1!/1+2!/2+3!/3+4!/4+...n!/n i just want the main logic as i m nt
java programs
java programs  A union B, transpose of matric, denomination of a given number i need java programs for this category?   Hi Friend, Transpose of matrix: import java.util.*; public class Transpose { public
JSF Sample Programs
JSF Sample Programs  I need a JSF sample programs
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
Explain types of java programs
Explain types of java programs  Explain types of java programs   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
RUNNING EJB PROGRAMS
RUNNING EJB PROGRAMS  how to run ejb programs using weblogic in windowsxp
advantage of stored programs
advantage of stored programs  Which of the following is an advantage of stored programs? a) Reliability b)Reduction in operation costs c) The computers becoming general purpose D) All of the above E) None of these  
how to compile programs??????????
how to compile programs??????????  "javac" is not recognised as a file name. why??????????   Have you set your path name and class name correctly? Anyways have a look at the following link: Install Java
j2ee example programs
j2ee example programs   can any one tell me how to develop and execute ---------- j2ee entity beans (cmp,bmp) example,message driven bean example ,webservices example in weblogic server with (netbeans or eclipse
user define exception programs
user define exception programs  user define exception programs   Please visit the following links: http://www.roseindia.net/java/java-exception/user-defined-exception.shtml http://www.roseindia.net/java/exceptions
Java programs - Java Beginners
Java programs  Hello Please write the following programs for me using GUI.Thanks You. 1. Write a java program that reads the first name, last name, hours worked and hourly rate for an employee. Then print the name
i want code for these programs
i want code for these programs   Advances in operating system Laboratory Work: (The following programs can be executed on any available and suitable platform) Design, develop and execute a program using any
Java programs on students assesment
Java programs on students assesment  1) Write a Java program that reads the details of student and do the mark assessments. (i) Input the name of the student and student id from the user. (Use String variable to hold the student
Tutorials   
Java Spring Hibernate Struts Training Default value of path variable in Windows 7 Windows 7 refresh DNS 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) how to change a column data in a every row in a text file in java cursor location what is the Advantages moqui framework vs other frameworks what is the difference between moqui framework vs other frameworks Develop Bulk SMS sender Bundle of servers interface ALU Computer Term How to find the size of a dynamic webpage using java... eg : Youtube........ Question in Create Arraylist ? active window means 1024 bytes equals to can a volatile memory loss data on power cut What is E-Learning? What is E-Learning? What is hacker? different types of storage devices of a computer Examples of optical disk Main job of cpu Main memory is also known as Define computer software. connection between your computer and local isp which part of the cpu does math calculations What is procedure Where i can use UNIX Operating System? What was ENIAC One byte consists of how many bits? What is the use of Bluetooth technology basic function of computer system how to measure data transfer speed GIGO Full Form What is parallel port where are program instructions and data values stored Nible is a computer network is referred as The input device used by computer is The product of data processing is The CPU(Central processing unit)consist of One-thousand of a second is called Alternate facilities of programs, data files, hardware equipment, etc. One-Millionth of a second is referred as Storage medium that loses its contents A LSI chip contains the entire CPU of computer except main memory is called ascending order of a data hierarchy Combining records from two or more orders files into a single ordered file is called Computer questions for Bank PO Exams and upsc competitive exams characteristics of a modem computer

Ads

 
Advertisement null

Ads