Sunday, 17 December 2017
java program print the number of table
import java.awt.Toolkit;import java.util.Calendar;import java.util.GregorianCalendar;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import java.io.*;import com.sun.speech.freetts.*;
Thursday, 7 December 2017
java calculatore
package bilaly;
import javax.swing.*;
import java.awt.event.*;
public class Main implements ActionListener{
JTextField tf1,tf2,tf3;
JButton b1,b2,b3,b4;
Main(){
JFrame f= new JFrame();
tf1=new JTextField();
tf1.setBounds(50,50,150,20);
tf2=new JTextField();
tf2.setBounds(50,100,150,20);
tf3=new JTextField();
tf3.setBounds(50,150,150,20);
tf3.setEditable(false);
b1=new JButton("+");
b1.setBounds(20,200,50,50);
b2=new JButton("-");
b2.setBounds(80,200,50,50);
b3=new JButton("x");
b3.setBounds(200,200,50,50);
b4=new JButton("/");
b4.setBounds(140,200,50,50);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
f.add(tf1);f.add(tf2);f.add(tf3);f.add(b1);f.add(b2); f.add(b3);f.add(b4);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String s1=tf1.getText();
String s2=tf2.getText();
Double a = new Double(s1);
Double b= new Double(s2);
double c=0;
if(e.getSource()==b1){
c=a+b;
}else if(e.getSource()==b2){
c=a-b;
} else if(e.getSource()==b3){
c=a*b;
} else if(e.getSource()==b4){
c=a/b;
}
String result=String.valueOf(c);
tf3.setText(result);
}
public static void main(String[] args) {
new Main();
} }
Monday, 20 November 2017
Using java build a beautiful clock display current time
THIS IS THE CODE TO DISPLAY A BEAUTIFUL CLOCK
package javaaa;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.*;
public class Javaaa extends JApplet {
public static void main(String s[]) {
JFrame frame = new JFrame();
frame.setTitle("Clock");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new Javaaa();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
}
public void init() {
JPanel panel = new ClockPanel();
getContentPane().add(panel);
}
}
class ClockPanel extends JPanel implements ActionListener{
AffineTransform rotH = new AffineTransform();
AffineTransform rotM = new AffineTransform();
AffineTransform rotS = new AffineTransform();
public ClockPanel() {
setPreferredSize(new Dimension(640, 480));
setBackground(Color.white);
Timer timer = new Timer(500, this);
timer.start();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
Font currentFont = g2.getFont();
g2.translate(320,240);
// clock face
Paint paint = new GradientPaint
(-140,-140,Color.GREEN,-10,-10,Color.ORANGE);
g2.setPaint(paint);
g2.fillOval(-210, -210, 420, 420);
g2.setColor(Color.red);
Font newFont = currentFont.deriveFont(currentFont.getSize() * 3.4F);
g2.setFont(newFont);
g2.drawString("CLOCK", -70, 80);
g2.setColor(Color.black);
Font newFont1 = currentFont.deriveFont(currentFont.getSize() * 2.4F);
g2.setFont(newFont1);
g2.drawString("12", -18, -140);
g2.drawString("3", 134, 19);
g2.drawString("6", -8, 159);
g2.drawString("9", -149, 20);
Stroke stroke = new BasicStroke(3);
g2.setStroke(stroke);
g2.drawOval(-210, -210, 420, 420);
for (int i = 0; i < 24; i++) {
g2.rotate(2*Math.PI/12);
if(i%2==0)
g2.setColor(Color.BLUE);
else
g2.setColor(Color.red);
g2.fill3DRect(-30, -200, 60, 30, true);
}
// clock hands
Shape hour = new Line2D.Double(0, 0, 0, -100);
hour = rotH.createTransformedShape(hour);
Shape minute = new Line2D.Double(0, 0, 0, -140);
minute = rotM.createTransformedShape(minute);
Shape second = new Line2D.Double(0, 0, 0, -170);
second = rotS.createTransformedShape(second);
g2.setColor(Color.MAGENTA);
g2.setStroke(new BasicStroke(10,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2.draw(hour);
g2.draw(minute);
g2.setStroke(new BasicStroke(4));
g2.draw(second);
}
public void actionPerformed(ActionEvent e) {
int hour = Calendar.getInstance().get(Calendar.HOUR);
int min = Calendar.getInstance().get(Calendar.MINUTE);
int sec = Calendar.getInstance().get(Calendar.SECOND);
rotH.setToRotation(Math.PI * (hour+min/60.0)/6.0);
rotM.setToRotation(Math.PI * min /30.0);
rotS.setToRotation(Math.PI * sec /30.0);
repaint();
}}
OUTPUT
Wednesday, 15 November 2017
java graphical prjects
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400,h=1,j=1,k=1,l=1;
for(int i=0;i<14;i++)
{
Ellipse2D.Double R= new Ellipse2D.Double(d,s,d,f);
g2.draw(R);
Rectangle E= new Rectangle(s,s,a,f);
g2.draw(E);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
if(i%2==1){
g2.setColor(Color.green
);
g2.fill(E);}
if(i%2==0)
{ g2.setColor(Color.yellow);
g2.fill(E);}
if(i%2==1)
{ g2.setColor(Color.red);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
h+=1;j+=1;k+=1;l+=1;
}}
}
Output is
java graphics projects
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400,h=1,j=1,k=1,l=1;
for(int i=0;i<14;i++)
{
Ellipse2D.Double R= new Ellipse2D.Double(s,s,d,f);
g2.draw(R);
Rectangle E= new Rectangle(h,s,d,f);
g2.draw(E);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
if(i%2==1){
g2.setColor(Color.green
);
g2.fill(E);}
if(i%2==0)
{ g2.setColor(Color.yellow);
g2.fill(E);}
if(i%2==1)
{ g2.setColor(Color.red);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
h+=1;j+=1;k+=1;l+=1;
}}
}
Output is
java full 3d drawings
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400,h=1,j=1,k=1,l=1;
for(int i=0;i<14;i++)
{
Ellipse2D.Double R= new Ellipse2D.Double(1,s,d,f);
g2.draw(R);
Rectangle E= new Rectangle(a,l,d,f);
g2.draw(E);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
if(i%2==1){
g2.setColor(Color.green
);
g2.fill(E);}
if(i%2==0)
{ g2.setColor(Color.yellow);
g2.fill(E);}
if(i%2==1)
{ g2.setColor(Color.red);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
h+=1;j+=1;k+=1;l+=1;
}}
}
Output is
java 3d drawing top 10 programs
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400;
for(int i=0;i<14;i++)
{
Ellipse2D.Double R= new Ellipse2D.Double(a,s,d,f);
g2.draw(R);
Rectangle E= new Rectangle(a,s,d,f);
g2.draw(E);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
if(i%2==1){
g2.setColor(Color.green
);
g2.fill(E);}
if(i%2==0)
{ g2.setColor(Color.yellow);
g2.fill(E);}
if(i%2==1)
{ g2.setColor(Color.red);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
}}
}
Output is
java program that print circles in circles
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400;
for(int i=0;i<14;i++)
{
Ellipse2D.Double R= new Ellipse2D.Double(a,s,d,f);
g2.draw(R);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
else
{ g2.setColor(Color.red);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
}}
}
Output is
java graphical programs
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=16,s=30,d=400,f=400;
for(int i=0;i<14;i++)
{
Rectangle R= new Rectangle(a,s,d,f);
g2.draw(R);
if(i%2==0)
{ g2.setColor(Color.BLACK);
g2.fill(R);
}
else
{ g2.setColor(Color.green);
g2.fill(R);
}
a+=14;s+=14;d-=30;f-=30;
}}
}
Output is
java program that print olympic rings
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Ellipse2D.Double R= new Ellipse2D.Double(128,20,110,110);
g2.draw(R);
g2.setColor(Color.black);
g2.fill(R);
Ellipse2D.Double R2= new Ellipse2D.Double(138,30,90,90);
g2.draw(R2);
g2.setColor(Color.white);
g2.fill(R2);
Ellipse2D.Double R3= new Ellipse2D.Double(12,20,110,110);
g2.draw(R3);
g2.setColor(Color.BLUE);
g2.fill(R3);
Ellipse2D.Double R4= new Ellipse2D.Double(22,30,90,90);
g2.draw(R4);
g2.setColor(Color.white);
g2.fill(R4);
Ellipse2D.Double R7= new Ellipse2D.Double(244,20,110,110);
g2.draw(R7);
g2.setColor(Color.red);
g2.fill(R7);
Ellipse2D.Double R8= new Ellipse2D.Double(254,30,90,90);
g2.draw(R8);
g2.setColor(Color.white);
g2.fill(R8);
Ellipse2D.Double R9= new Ellipse2D.Double(194,95,110,110);
g2.draw(R9);
g2.setColor(Color.green);
g2.fill(R9);
Ellipse2D.Double R10= new Ellipse2D.Double(204,105,90,90);
g2.draw(R10);
g2.setColor(Color.white);
g2.fill(R10);
Ellipse2D.Double R11= new Ellipse2D.Double(65,95,110,110);
g2.draw(R11);
g2.setColor(Color.yellow);
g2.fill(R11);
Ellipse2D.Double R12= new Ellipse2D.Double(75,105,90,90);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
}
}
Output is
java top 10 programs that print beautiful images
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=1,s=1,d=12,f=1,l=1,h=1,j=1,k=1;
for(int z=0;z<100;z++) {
Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
g2.draw(R11);
g2.setColor(Color.yellow);
g2.fill(R11);
Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
a+=3;s+=3;d+=3;f+=3;h+=1;j+=1;k+=1;l+=1;
}
a=200;s=200;d=200;f=200;l=200;h=200;j=200;k=200;
for(int z=0;z<100;z++) {
Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
g2.draw(R11);
g2.setColor(Color.MAGENTA);
g2.fill(R11);
Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
a+=3;s-=3;d-=3;f-=3;h-=1;j-=1;k-=1;l-=1;
}}
}
Output is
java beautiful rings program
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void
paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Ellipse2D.Double R= new Ellipse2D.Double(128,20,110,110);
g2.draw(R);
g2.setColor(Color.blue);
g2.fill(R);
Ellipse2D.Double R2=
new Ellipse2D.Double(138,30,90,90);
g2.draw(R2);
g2.setColor(Color.white);
g2.fill(R2);
Ellipse2D.Double R3= new Ellipse2D.Double(12,20,110,110);
g2.draw(R3);
g2.setColor(Color.green);
g2.fill(R3);
Ellipse2D.Double R4=
new Ellipse2D.Double(22,30,90,90);
g2.draw(R4);
g2.setColor(Color.white);
g2.fill(R4);
Ellipse2D.Double R7= new Ellipse2D.Double(244,20,110,110);
g2.draw(R7);
g2.setColor(Color.red);
g2.fill(R7);
Ellipse2D.Double R8=
new Ellipse2D.Double(254,30,90,90);
g2.draw(R8);
g2.setColor(Color.white);
g2.fill(R8);
Ellipse2D.Double R9= new Ellipse2D.Double(244,121,110,110);
g2.draw(R9);
g2.setColor(Color.red);
g2.fill(R9);
Ellipse2D.Double R10=
new Ellipse2D.Double(254,131,90,90);
g2.draw(R10);
g2.setColor(Color.white);
g2.fill(R10);
Ellipse2D.Double R11= new Ellipse2D.Double(12,121,110,110);
g2.draw(R11);
g2.setColor(Color.green);
g2.fill(R11);
Ellipse2D.Double R12=
new Ellipse2D.Double(22,131,90,90);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
Ellipse2D.Double R18= new Ellipse2D.Double(128,121,110,110);
g2.draw(R18);
g2.setColor(Color.blue);
g2.fill(R18);
Ellipse2D.Double R19=
new Ellipse2D.Double(138,131,90,90);
g2.draw(R19);
g2.setColor(Color.white);
g2.fill(R19);
}
}
Output is
java very beautiful drawing
This is main class
package graphs;
import javax.swing.*;
public class Graphs {
public static void main(String[] args) {
String title="ALLAH IS ONE";
JFrame f= new JFrame();
f.setSize(700,700);
f.setTitle(title);
paints P= new paints();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
After writing main class create a class of paints and call it in main class
package graphs;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class paints extends JComponent {
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int a=1,s=1,d=1,f=1,l=1,h=1,j=1,k=1;
for(int z=0;z<100;z++) {
Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
g2.draw(R11);
g2.setColor(Color.yellow);
g2.fill(R11);
Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
a+=3;s+=3;d+=3;f+=3;h+=1;j+=1;k+=1;l+=1;
}
a=200;s=200;d=200;f=200;l=200;h=200;j=200;k=200;
for(int z=0;z<100;z++) {
Ellipse2D.Double R11= new Ellipse2D.Double(a,s,d,f);
g2.draw(R11);
g2.setColor(Color.MAGENTA);
g2.fill(R11);
Ellipse2D.Double R12= new Ellipse2D.Double(h,j,k,l);
g2.draw(R12);
g2.setColor(Color.white);
g2.fill(R12);
a+=3;s+=3;d-=3;f-=3;h-=1;j-=1;k-=1;l-=1;
}}
}
Output is
Subscribe to:
Posts (Atom)












