Recent Posts

Connect On Facebook

Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Saturday, 2 July 2011

Eviewbox DICOM Viewer Java Source code

Eviewbox is a java imaging Application,It view and spread native DICOM medical images and allowing for 2D reconstructions. This code available on internet on sourceforge.net.This  DI-COM Viewer views the medical images .dcm file.In internet Lot of dcm Databases are availabe.you have download dcm database then download the source code and Run this application.
In below we provide the screen shot of Eviewbox - Di-com viewer.



Keyword : Dicom Viewer Source code,DICOM medical images Viewer Source code,DICOM medical images source code,DICOM Viewer source code,Java-based Dicom viewer (with source code),Dicom viewer sample code,DICOM Viewer for windows source code.

Saturday, 23 April 2011

Report to Server Using RMI

This RMI Program to report The content in remote Server.This Code will use to for report your Server.Remote method invocation is best one in Java.In below example code this technique will use.please usea as following steps to run this program.




Steps:

1) create serializale Interface DataBaseAccessMethods
2) create DataBaseAction
3) create ReportServer(Rmi Server)
4) create ReportUser(Client)
5) run commandpromt  rmic DataBaseAction
6) run rmiregistry with port
7) run RmiServer(ReportServer)
8) run Rmiclient(ReportUser)

DataBaseAccessMethods.java

import java.rmi.*;
import java.awt.*;
public interface DataBaseAccessMethods extends Remote
{
    public String login(String username,String Password)throws RemoteException,Exception;
      public void reportMsgs(String user,String msg,String place,String cdate)throws RemoteException,Exception;
      public void connection() throws RemoteException,Exception;
      public void close() throws RemoteException,Exception;
}


DataBaseAccessMethods.java

In this program Overwrite the DataBaseAccessMethods class...

import java.io.*;
import java.rmi.*;
import java.awt.*;
import java.rmi.server.UnicastRemoteObject;
import java.sql.*;
public class DataBaseAction extends UnicastRemoteObject implements DataBaseAccessMethods
{
    String url = "jdbc:odbc:report";
    String userID = "";
    String password = "";
    Statement DataRequest;
    Connection Db;
    ResultSet Results;
    PreparedStatement DataRequest1;
   
    String FirstName;
    String LastName;
    String printrow;
           
    public void connection() throws RemoteException,Exception
    {
        //try
        {
            Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
            Db = DriverManager.getConnection(url,userID,password);
        }
        //catch(Exception e)
        {
          //  System.out.println("Connection Error:"+e);
        }
    }
   
   
   
   
   
    public DataBaseAction()throws RemoteException
    {
        //System.out.println("Rmi Server is ready");
        super();
    }
  
   
    public String login(String username,String password)throws RemoteException,Exception
    {
        String name="";
        //try
        {
            connection();
            String query = "SELECT * FROM users where Username='"+username+"' and Password='"+password+"'";
            DataRequest = Db.createStatement();
            Results = DataRequest.executeQuery (query);
           
           
           
            boolean Records = Results.next();
            if (!Records )
            {
                name="";
            }
            else
            {
                name = Results.getString ("Name") ;
               
            }
            close();
        }
        //catch(Exception e)
        {
//            System.out.println("Select Action Error:"+e);
        }
        return name;
    }
    public void reportMsgs(String user,String msg,String place,String cdate)throws RemoteException,Exception
    {
  //      try
        {
            connection();
            String query = "insert into msgs (users,place,message,Cdate) values ('"+user+"','"+msg+"','"+place+"',#"+cdate+"#)";
            System.out.println(query);
            DataRequest = Db.createStatement();
            DataRequest.executeUpdate(query);
            close();
        }
    //    catch(Exception e)
        {
      //      System.out.println("Insert Action Error:"+e);
        }
    }
    public void close() throws RemoteException,Exception
    {
        //try
        {
            DataRequest.close();
            DataRequest.close();
            Db.close();
        }
        //catch(Exception e)
        {
          //  System.out.println("Close Error:"+e);
        }
    }
      
}       

Design a RMI server...

DataBaseAccessMethods.java


import java.io.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class ReportServer
{
    public static void main(String arg[])throws Exception
    {
        //try
        {
                    DataBaseAction s1=new DataBaseAction();
                    Naming.rebind("Reporting",s1);
                    System.out.println("Report Server is ready");
        }
        //catch(RemoteException e)
        {
        //    System.out.println(e);
        }
    }
}

Design a RMI Client....

ReportUserWindow.java

import java.net.*;
import java.io.DataInputStream;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import javax.swing.*;
import java.awt.event.*;
import java.util.Date;

import java.awt.*;
public class ReportUserWindow
{
    public static void main(String arg[])throws Exception
    {
        WindowD win=new WindowD();
    }
       
}
class WindowD extends JFrame implements ActionListener
{
    Date d;
    JPanel left, right, top, bottom, center;// Panels
    JLabel banner;
    //JFrame win;
    JLabel uname,pass;
    JTextField tuname;
    JPasswordField tpass;
    JButton login,send;
   
   
    JLabel username,date,msgs,place;
    JTextField tusername,tdate,tplace;
    JTextArea tmsgs;
    JScrollPane smsgs;
   
    WindowD()
    {
        d=new Date();
        setLayout(new BorderLayout());
        left = new JPanel();
        right = new JPanel();
        top = new JPanel();
        bottom = new JPanel();
        center = new JPanel();
        add(left, BorderLayout.WEST);
        add(right, BorderLayout.EAST);
        add(top, BorderLayout.NORTH);
        add(bottom, BorderLayout.SOUTH);
        add(center, BorderLayout.CENTER);
        uname=new JLabel("Username:");
        pass=new JLabel("Password:");
        tuname=new JTextField();
        tpass=new JPasswordField();
       
        login=new JButton("Login");
        center.setLayout(null);
        uname.setBounds(20,20,80,20);
        center.add(uname);
        tuname.setBounds(120,20,80,20);
        center.add(tuname);
        pass.setBounds(20,50,80,20);
        center.add(pass);       
       
        tpass.setBounds(120,50,80,20);
        center.add(tpass);
       
        login.setBounds(120,80,80,20);
        center.add(login);
       
        center.setSize(100,100);
       
        banner = new JLabel("------------Reporter---------");
        top.add(banner);
        setSize(300, 400);
    setVisible(true);
        login.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
        JButton mi = (JButton)e.getSource();
    String s = mi.getText();
       
    if (s.equals("Login"))
    {
            try
            {
               String stuname=tuname.getText();
               String stpass=tpass.getText();
               Object obj=Naming.lookup("Reporting");
               DataBaseAccessMethods data=(DataBaseAccessMethods)obj;
               String rname=data.login(stuname,stpass);
               if(!rname.equals(""))
               {
                    System.out.println("gggg"+rname);
                    center.removeAll();
                    repaint();
                    username=new JLabel("Username:");
                    date=new JLabel("Date:");
                    msgs=new JLabel("Messages:");
                    place=new JLabel("Place:");;
                   
                    tusername=new JTextField();
                    tusername.setText(rname);
                   
                   
                    int date1=d.getDate();
                    int month=d.getMonth();
                    int year1=d.getYear();
                    String sss=d.toGMTString();
                    tdate=new JTextField();
                    tdate.setText(""+date1+"/"+month+"/"+year1);
                    System.out.println(sss);
                    tmsgs=new JTextArea();
                    smsgs=new JScrollPane(tmsgs);
                    tmsgs.setText("");
                    tplace=new JTextField();
                    send=new JButton("Send");
                    send.addActionListener(this);
                    username.setBounds(20,20,80,20);
                    tusername.setBounds(120,20,80,20);
                    date.setBounds(20,50,80,20);
                    tdate.setBounds(120,50,80,20);
                    msgs.setBounds(20,80,80,20);
                    smsgs.setBounds(120,80,80,60);
                    place.setBounds(20,150,80,20);
                    tplace.setBounds(120,150,80,20);
                    send.setBounds(120,180,80,20);
                    center.add(username);
                    center.add(tusername);
                    center.add(date);
                    center.add(tdate);
                    center.add(msgs);
                    center.add(smsgs);
                    center.add(place);
                    center.add(tplace);
                    center.add(send);
               }
           }
       catch(Exception ee)
       {
        System.out.println(ee);
       }
        }
        if (s.equals("Send"))
    {
            try
            {
               String stuname=tusername.getText();
               String cdate=tdate.getText();
               String msg=tmsgs.getText();
               String place=tplace.getText();
               Object obj=Naming.lookup("Reporting");
               DataBaseAccessMethods data=(DataBaseAccessMethods)obj;
               data.reportMsgs(stuname,msg,place,cdate);
               tmsgs.setText("");
               tplace.setText("");
              
           }
       catch(Exception ee)
       {
        System.out.println(ee);
       }
        }
    }
}

Java Remote Desktop Monitoring

Following Code used to Remote Desktop Monitoring....
This following code to capture the client Screen and send it to the server.Server to Record the Screen on hard disk .This program to implement the Server socket concept.This code is very good one.here not implement Multi-threading.you have used to multi threading and captures all you client screen

ImageCapture.java

1.This code client side code

2. This code Capture the current window screen and sends to particular server system .


import java.io.*;
import java.awt.*;
import java.awt.Image.*;


import java.net.*;
import java.io.File;
import java.util.*;
import java.lang.*;


import java.awt.Image;
import java.io.Serializable;
import java.applet.Applet;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.undo.*;
import javax.swing.colorchooser.ColorChooserComponentFactory;
import sun.beans.editors.StringEditor;
import javax.swing.plaf.MenuBarUI;
import javax.swing.text.*;
   
import javax.imageio.ImageIO;
import java.net.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.geom.*;


public class ImageCapture implements Runnable
{
        boolean act=true;
        public Robot robo;
        byte [] dataone;
        int count=0;
        public BufferedImage myImage;
        //public  InetAddress multicastAddress;
        public  Socket socket;
        Thread main;
        public static void main(String args[])
        {
                try
                {
                       ImageCapture img=new ImageCapture();
                 }
                catch(Exception e)
                {
                        System.out.println("Errr inImgcanvas "+e);
                }
        }
        public ImageCapture()
        {
                try
                {
                        robo=new Robot();
                            if(act==true)
                            {
                                main=new Thread(this);
                                main.start();
                                System.out.println("Started");
                            }
                            else
                            {
                                main.stop();
                                System.out.println("Stoped");   
                            }
                       
                }
                catch(Exception e)
                {
                        System.out.println("Errr inImgcanvas cons "+e);
                }
        }


       public void run()
        {
                try
                {
                   
                      for (;;)
                    {
                            //if(act==true)
                            {
                                System.out.println("Started");
                                myImage=robo.createScreenCapture(new Rectangle(0,0,800,800));                              


                                int x1=155;int y1=150;int x2=205;int y2=185;
                                int red = 255;
                                int green = 0;
                                int blue = 0;
                                int transparency =100;
                               
                                Graphics graphics = myImage.getGraphics();
                                Color color = new Color(red, green,blue,255 * transparency/100);
                                graphics.setColor(color);
                                graphics.drawString("Screen Capture " +new java.util.Date(),50, myImage.getHeight() - 10);
                                int thumbWidth=500,thumbHeight=500;
                                double thumbRatio =(double)thumbWidth /(double)thumbHeight;
                                int imageWidth =myImage.getWidth(null);
                                int imageHeight=myImage.getHeight(null);
                                double imageRatio =(double)imageWidth / (double)imageHeight;
                                if (thumbRatio <imageRatio) {
                                        thumbHeight =(int)(thumbWidth /imageRatio);
                                } else {
                                        thumbWidth =(int)(thumbHeight *imageRatio);
                                }
                                BufferedImage thumbImage = new BufferedImage(thumbWidth,thumbHeight,BufferedImage.TYPE_INT_RGB);
                                Graphics2D graphics2D=thumbImage.createGraphics();
                                graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                                graphics2D.drawImage(myImage, 0, 0,thumbWidth,thumbHeight, null);
                                BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("screencapture.jpg"));
                                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                                JPEGEncodeParam param= encoder.getDefaultJPEGEncodeParam(thumbImage);
                                int quality =Integer.parseInt("75");
                                quality = Math.max(0,Math.min(quality,100));
                                param.setQuality((float)quality / 100.0f,false);
                                encoder.setJPEGEncodeParam(param);
                                encoder.encode(thumbImage);
                                File file=new File("screencapture.jpg");
                                RandomAccessFile f=new RandomAccessFile(file,"r");
                                System.out.println("transmit len="+f.length());
                                byte [] data = new byte[(int)f.length()];
                                if(count++==0)
                                        dataone=new byte[data.length];
                                f.read(data);
                              
                if(dataone.length!=data.length)
                                {


                                    System.out.println("Transmitting");
                                    socket = new Socket("localhost",8080);
                                    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
                                    oos.writeObject(file);
                                }
                                dataone=data;
                                f.close();
                                file.delete();
                                main.sleep(2000);
                            }
                           
                      }
                }
                catch(Exception e)
                {
                     System.out.println("Errr in Imgcanvas thread "+e);
                }
               
               
        }
   
}


Monitor.java 


This code read the client scree and displays the screening images...


import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.geom.*;
import javax.swing.*;


public class Monitor
{
    public static void main(String args[])throws Exception
    {
                JFrame f1=new JFrame();
                JLabel jl3=new JLabel();
        ServerSocket sck=new ServerSocket(8080);
                f1.setSize(400,300);
                f1.setVisible(true);
                        while(true)
                        {
                            f1.repaint();
                            Socket server=sck.accept();
                            ObjectInputStream entrada= new ObjectInputStream(server.getInputStream());
                            File file=(File)entrada.readObject();
                            Image image = ImageIO.read(file);
                            ImageIcon imgvar=new ImageIcon(image);
                            jl3.setIcon(imgvar);
                            f1.add(jl3);
                           
    }                    }
}

Wednesday, 2 March 2011

Find Name - Pazzle Java Program

"Find Name"  if you run this java program then you thinkable name will produce. just you copy The Program run it your system you got the result .If you like this program means please comments me.Thank you.


import java.io.*;
class NameDetect
{
char a[]=new char[8];
char b[]=new char[8];
char c[]=new char[10];
char end[];
char d='a';
int j=0,k=0,m=0;
int main[];
int main1[];

NameDetect()throws Exception
{
DataInputStream dis=new DataInputStream(System.in);
System.out.println("\t\t\tGUESS NAME DETECTOR");
System.out.print("\tHow many letters Your gess name:");
int val=Integer.parseInt(dis.readLine());
System.out.println("...............................................");
main=new int[val];
for(int i=0;i<val;i++)
{
display();
int kkkk=i+1;
System.out.print("\n\tEnter "+kkkk+" letter section:");
main[i]=Integer.parseInt(dis.readLine());
System.out.println("...............................................");
j=0;k=0;m=0;
d='a';
}
main1=new int[main.length];
end=new char[main.length];
for(int i=0;i<main.length;i++)
{
display2();
int kkkk=i+1;
System.out.print("\n\tEnter "+kkkk+" letter section:");
int ok=Integer.parseInt(dis.readLine());
System.out.println(".................................................................");
if(main[i]==3)
{
end[i]=c[ok-1];
}
if(main[i]==2)
{
end[i]=b[ok-1];
}
if(main[i]==1)
{
end[i]=a[ok-1];
}
}
System.out.print("\nYour guess name is:");
for(int i=0;i<end.length;i++)
{
System.out.print(end[i]);
}
}
void display2()
{
for(int i=0;i<main.length;i++)
{
int kk=8,mm=10;
if(main[i]==3)
{
display1(kk,c);
}
if(main[i]==2)
{
display1(mm,b);
}
if(main[i]==1)
{
display1(mm,a);
}
}
}
void display1(int kkk,char aaa[])
{
for(int i=0;i<aaa.length;i++)
{
System.out.print(aaa[i]+"\t");
}
System.out.print("\n");
}
void display()
{
for(int i=0;i<=26;i++)
{
if(i<8)
{
a[j]=d;
d++;
j++;
}
if(i>8&&i<=16)
{
b[k]=d;
d++;
k++;
}
if(i>16&&i<=26)
{
c[m]=d;
d++;
m++;
}
}
for(int i=0;i<10;i++)
{
if(i<8)
{
System.out.println(a[i]+"\t"+b[i]+"\t"+c[i]);
}
else
{
System.out.println("\t\t"+c[i]);
}
}
}

}
class FindName
{
public static void main(String s[])throws Exception
{
NameDetect aa=new NameDetect();
}
}

keywords: Find Name  - Pazzle Java Program | Pazzle java Program | Find the Name pazzle java Program,Interesting java program

Guess Number - Puzzle java Program


This java program is most Interesting java program.This program is find your guessable number.Most interesting java program .Just Copy this code and run it your system.This code Guess your number.if you like this program  means please comments me .Thank you

import java.io.*;
class Find
{
int aaa[]=new int[22];
int[] find(int a[],int b[],int c[])
{
int m=0;
int nnn=0;
int kkk=0;
int mmm=1;
for(int i=0;i<21;i++)
{
if(i<7)
{
aaa[mmm]=a[m];
}
if(i>=7&&i<14)
{
aaa[mmm]=b[nnn];
nnn++;
}
if(i>=14)
{
aaa[mmm]=c[kkk];
kkk++;
}

m++;
mmm++;


}
return aaa;
}
}
class Guess
{
public static void main(String s[])throws Exception
{
System.out.print("Your Guess any number 1 to 21\n\n");
DataInputStream dis=new DataInputStream(System.in);
int a[]=new int[7];
int b[]=new int[7];
int c[]=new int[7];
int d[]=new int[7];
int e[]=new int[7];
int f[]=new int[7];
int aaa[]=new int[22];
int m=0;
System.out.print("\n\tBlock1\t\tBlock2\t\tBlock3\t\n\n");
for(int i=0;i<21;i=i+3)
{
a[m]=i+1;
b[m]=i+2;
c[m]=i+3;
System.out.print("\t"+a[m]+"\t");
System.out.print("\t"+b[m]+"\t");
System.out.print("\t"+c[m]);
System.out.println("\n");
m++;
}
System.out.print("What Block Your Guess number:");
int h=Integer.parseInt(dis.readLine());
System.out.print("\n\n");
if(h==1)
{
Find ff=new Find();
aaa=ff.find(b,a,c);

}
if(h==2)
{
Find ff=new Find();
aaa=ff.find(a,b,c);
}
if(h==3)
{
Find ff=new Find();
aaa=ff.find(a,c,b);
}
m=0;
System.out.print("\n\tBlock1\t\tBlock2\t\tBlock3\t\n\n");
for(int i=0;i<21;i=i+3)
{
a[m]=aaa[i+1];
b[m]=aaa[i+2];
c[m]=aaa[i+3];
System.out.print("\t"+a[m]+"\t");
System.out.print("\t"+b[m]+"\t");
System.out.print("\t"+c[m]);
System.out.println("\n");
m++;
}
System.out.print("What Block Your Guess number:");
h=Integer.parseInt(dis.readLine());
System.out.print("\n\n");
if(h==1)
{
Find ff=new Find();
aaa=ff.find(b,a,c);

}
if(h==2)
{
Find ff=new Find();
aaa=ff.find(a,b,c);
}
if(h==3)
{
Find ff=new Find();
aaa=ff.find(a,c,b);
}
m=0;
System.out.print("\n\tBlock1\t\tBlock2\t\tBlock3\t\n\n");
for(int i=0;i<21;i=i+3)
{
a[m]=aaa[i+1];
b[m]=aaa[i+2];
c[m]=aaa[i+3];
System.out.print("\t"+a[m]+"\t");
System.out.print("\t"+b[m]+"\t");
System.out.print("\t"+c[m]);
System.out.println("\n");
m++;
}
System.out.print("What Block Your Guess number:");
h=Integer.parseInt(dis.readLine());
System.out.print("\n\n");
if(h==1)
{
Find ff=new Find();
aaa=ff.find(b,a,c);

}
if(h==2)
{
Find ff=new Find();
aaa=ff.find(a,b,c);
}
if(h==3)
{
Find ff=new Find();
aaa=ff.find(a,c,b);
}
System.out.println("Your Guess Number is:"+aaa[11]);
}
}

Keyword : Puzzle Java program | Guess Number java Program | java Program Puzzle | Interesting java Program | Likeable java Program

Popular Posts

Disclaimer

This blog-spot does not host any files mentioned on this blog or on its own servers. He emphasized that to various links on the Internet that already exist and are uploaded by other websites or users there. Links to albums will be removed if a complaint with the artist or publisher.