Thursday, January 19, 2012

How to create a Zodiac sign program in java then the output will be the picture of your zodiac sign?

I hope it is possible in java to do a program like that.

Thank you.How to create a Zodiac sign program in java then the output will be the picture of your zodiac sign?
It's actually very easy to make one but I'm assuming you have images you just want to have displayed based on a date of birth. There are hundreds of ways to write a program to get the same outcome even when the display is exactly the same so this is just a very fast example of one month. If you enter in 01 for the month and any day from 01-20 and any year the program will attempt to open a file names Capricorn.png and display it. The picture must be in the same location as the class file your attempting to run.





import javax.swing.*;

public class Zodiac extends JPanel {

ImageIcon icon;

Zodiac(){

String[] s=JOptionPane.showInputDialog

("MM/DD/YYYY").split("/");

int m=Integer.parseInt(s[0]);

int d=Integer.parseInt(s[1]);

if(m==1 %26amp; d%26lt;21){

icon=createImageIcon

("Capricorn.PNG");

}

add(new JLabel(icon));

}

public static void main(String args[]){

JFrame f=new JFrame("Zodiacs");

f.setDefaultCloseOperation(

JFrame.

EXIT_ON_CLOSE);

f.add(new Zodiac());

f.pack();

f.setVisible(true);

}



private ImageIcon createImageIcon(String path) {

System.out.println("creating imgs "+path);

java.net.URL imgURL = getClass().getResource(path);

if (imgURL != null) {



return new ImageIcon(imgURL);

} else {

System.out.println(imgURL);

System.err.println("Couldn't find file: " + path);

return null;

}

}

}How to create a Zodiac sign program in java then the output will be the picture of your zodiac sign?
It is possible but requires advance programming knowledge. You can pay someone to do it on freelancing sites.

No comments:

Post a Comment