Which Anti Virus

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Tuesday, 19 November 2013

GTU Paper Solution and Material as Per GTU syllabus

Posted on 06:46 by Unknown
Go to this website and download the Study material of GTU Syllabus.

http://gtu-paper.blogspot.com/


Read More
Posted in general, java | No comments

Saturday, 21 September 2013

Simple Demo Of RMI Registry Program

Posted on 20:18 by Unknown

Demointerface.java
/**
 *
 * @author Nish
 */

public interface DemoInterface extends java.rmi.Remote{
    
              public String sayDemo() throws java.rmi.RemoteException;

}

Demosever.java
import java.rmi.RemoteException;

import java.rmi.registry.LocateRegistry;

import java.rmi.server.UnicastRemoteObject;


/**
 *
 * @author Nish
 */

public class DemoServer implements DemoInterface{
    
String message;
    
public DemoServer(){
        
super();
    
}
    
public DemoServer(String msg){
        
message = msg;
   
 }    
    
@Override
    
public String sayDemo() throws RemoteException {

       return message;
    
}
    
public static void main(String []args){
  
      try {
            
DemoInterface  h = new DemoServer("Hello");
            
DemoInterface stub = (DemoInterface)UnicastRemoteObject.exportObject(h, 0);
            

java.rmi.registry.Registry reg = LocateRegistry.getRegistry();
  
          reg.rebind("Hello", stub);
            
System.out.println("Server is ready for Operation");
        
} 
catch (Exception ex) {}
        
    
}

}

Democlient.java

import java.rmi.registry.LocateRegistry;

import java.rmi.registry.Registry;

/**
 *
 * @author Nish
 */

public class DemoClient {
    
public static void main(String []args){
      
  try{
           
 Registry reg = LocateRegistry.getRegistry("localhost");

           DemoInterface h = (DemoInterface)reg.lookup("Hello");
            

System.out.println(h.sayDemo());
        
}
catch(Exception e){}
  
  }

}




Read More
Posted in java | No comments

Steps To Run RMI Program in JAVA

Posted on 20:06 by Unknown
Using the Following steps you can able to run your RMI program in JAVA 

1) First Comiple all java class
javac *.java
2) Then after start rmi registry
start rmiregistry
3) Then after generate stub and skelton using rmic,
rmic (implemented class)
4) Then after run server
java Server
5) Then after open new command prompt in same directory and run client
java Client
Read More
Posted in java | No comments

Sunday, 1 September 2013

Java Swing Look and Feel Feature-Example-Set Motif,Metal and Windows Look and Feel

Posted on 03:04 by Unknown
Write a following code in netbeans IDE 7.1 and save file as RegistrationForm.java and run it and you can able to set your look and feel in your application.  


package registrationform;

/**
 *
 * @author NISH
 */
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;

public class RegistrationForm extends JFrame implements ItemListener,ActionListener{
    JLabel title,lookfeel;
    JLabel l[]=new JLabel[7];
    JTextField t[]=new JTextField[7];
    JPasswordField tp;
    String lbl[]=new String[7];
    Container c;
    JComboBox cb;
    JRadioButton male,female;
    JOptionPane jop;
    ButtonGroup grp;
    JButton breg,bcncl;
    int vsp=80,hsp=100;
    int spx,spy;
    public RegistrationForm()
    {
        lbl[0]="Name :"; lbl[1]="Address :"; lbl[2]="Gender :"; lbl[3]="Email :"; lbl[4]="Phno :"; lbl[5]="Uname :"; lbl[6]="Password :";
        c=this.getContentPane();
        setLayout(null);
        lookfeel=new JLabel("Select LookAndFill :");
        lookfeel.setBounds(5, 5, 120, 20);
        c.add(lookfeel);
        cb=new JComboBox();
        cb.setBounds(125, 5, 75, 20);
        cb.addItem("Metal");
        cb.addItem("Motif");
        cb.addItem("Window");
        c.add(cb);
        title=new JLabel("Registration");
        title.setFont(new Font("Times New Roman", NORMAL, 20));
        title.setBounds(170, 30, 120,90);
        c.add(title);
       
        spy=30;
        spx=100;
        for(int i=0;i<=6;i++)
        {
            l[i]=new JLabel(lbl[i]);
            l[i].setBounds(vsp,hsp , 80, 40);
            hsp=hsp + spy;
            c.add(l[i]);
        }
        male=new JRadioButton("Male");
        female=new JRadioButton("Female");
        vsp=80;
        vsp=vsp+spx;
        hsp=110;
        for(int i=0;i<=6;i++)
        {
            t[i]=new JTextField("");
            if(i==2)
            {
                    male.setBounds(vsp,hsp, 60, 20);
                    c.add(male);
                    female.setBounds(vsp + 70,hsp, 100, 20);
                    c.add(female);
                    male.setSelected(true);
                    grp=new ButtonGroup();
                    grp.add(male);
                    grp.add(female);
            }
            else if(i==6)
            {
                tp=new JPasswordField();
                tp.setBounds(vsp, hsp, 170, 20);
                c.add(tp);
            }
            else
            {
                t[i].setBounds(vsp,hsp , 170, 20);
                c.add(t[i]);
            }
            hsp=hsp + spy;
        }
        breg=new JButton("Submit");
        breg.setBounds(110, hsp+spy, 90, 30);
        c.add(breg);
       
        bcncl=new JButton("Cancel");
        bcncl.setBounds(220, hsp+spy, 90, 30);
        c.add(bcncl);
        cb.addItemListener(this);
        breg.addActionListener(this);
        bcncl.addActionListener(this);
    }
    public static void main(String[] args) {
        RegistrationForm rg=new RegistrationForm();
        rg.setTitle("Registration Form");
        rg.setSize(450, 500);
        rg.setResizable(false);
        rg.show();
    }
    @Override
    public void itemStateChanged(ItemEvent e) {
        try {
            if(cb.getSelectedItem().toString() == "Metal")
            {
                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
            }
            if(cb.getSelectedItem().toString() == "Motif")
            {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
            }
            if(cb.getSelectedItem().toString() == "Window")
            {              UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            }
            SwingUtilities.updateComponentTreeUI(c);
        }
        catch(Exception ex)
        {
        }
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        jop=new JOptionPane();
        String str="";
        if(e.getSource().equals(breg))
        {
                for(int i=0;i<=6;i++)
                {
                    if(i==2)
                    {
                        if(male.isSelected())
                        {
                            str= str + lbl[i] + " " + "Male" + "\n";
                        }
                        else
                        {
                            str= str + lbl[i] + " " + "FeMale" + "\n";
                        }
                    }
                    else if(i==6)
                    {
                        str= str + lbl[i] + " " + tp.getText().toString() + "\n";
                    }
                    else
                    {  
                        str= str + lbl[i] + " " + t[i].getText().toString() + "\n";
                      
                    } 
                } 
               jop.showMessageDialog(c,str,null, JOptionPane.INFORMATION_MESSAGE);
        }
        for(int i=0;i<=6;i++)
        {
            t[i].setText("");
        }
        tp.setText("");
        if(e.getSource().equals(bcncl))
        {
            for(int i=0;i<=6;i++)
            {
                t[i].setText("");
            }
            tp.setText("");
        }
    }
}

Output:-

Read More
Posted in java | No comments

Make Analog Clock using java

Posted on 03:00 by Unknown
write a following code in netbeans IDE 7.1 and save file as Analogclock.java and run it and you will have your own Analog Clock... 

package analogclock;

/**
 *
 * @author NISH
 */
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Calendar;

/*
 <applet code="Clck" width=1500 height=3000>
 </applet>
 */
public class Analogclock extends Applet implements Runnable
{
    private static final double TWO_PI   = 2.0 * Math.PI;
    private Calendar nw = Calendar.getInstance();
    int width=300,hight=300;
    int xcent= width / 2,ycent= hight / 2;
    int minhand,maxhand;
    double rdns;
    int dxmin,dymin,dxmax,dymax;
    double radins,sine,cosine;
    double fminutes;
    Thread t=null;
    Boolean stopFlag;
  
    public void start()
    {
       t=new Thread(this);
       stopFlag = false;
       t.start();
    }
    public void run()
    {
       for( ; ; )
       {
              try {
                     updateTime();
                     repaint();
                     Thread.sleep(100);
                     if(stopFlag)
                        break;
                   }
              catch(InterruptedException e) {}
       }
    }
    public void stop()
    {
        stopFlag=true;
        t=null;
    }
    private void updateTime() {
       
        nw.setTimeInMillis(System.currentTimeMillis());
    }
    public void paint(Graphics g)
    {
        int hours   = nw.get(Calendar.HOUR);
        int minutes = nw.get(Calendar.MINUTE);
        int seconds = nw.get(Calendar.SECOND);
        int millis  = nw.get(Calendar.MILLISECOND);
        minhand=width /8;
        maxhand=width /2;
        rdns= (seconds + ((double)millis/1000)) / 60.0;
        drw(g,rdns,0,maxhand);
        g.drawString(hours + ":" + minutes + ":" + seconds,  minhand+90, maxhand+60);
        minhand = 0;                    // Minute hand starts in middle.
        maxhand = width / 3;
        fminutes = (minutes + rdns) / 60.0;
        drw(g, fminutes, 0, maxhand);
       minhand = 0;                    // Minute hand starts in middle.
        maxhand = width / 4;
        drw(g, (hours + fminutes) / 12.0, 0, maxhand);
        g.drawOval(0,0, width, hight);
        g.drawString("9", xcent-145, ycent -0);
        g.drawString("3", xcent+140, ycent -0);
        g.drawString("6",xcent , ycent+145);
        g.drawString("12",xcent , ycent-135);
     }
   
    public void drw(Graphics g,double prct,int minRadius, int maxRadius) 
    {
        radins= (0.5 - prct)* TWO_PI;
        sine   = Math.sin(radins);
        cosine = Math.cos(radins);
        dxmin = xcent + (int)(minRadius * sine);
        dymin = ycent + (int)(minRadius * cosine);
       
        dxmax = xcent + (int)(maxRadius * sine);
        dymax = ycent + (int)(maxRadius * cosine);
      
        g.drawLine(dxmin, dymin, dxmax, dymax);
    }
   

}

output:-

Read More
Posted in java | No comments
Older Posts Home
Subscribe to: Posts (Atom)

Popular Posts

  • Different Types Of Computer Ports
  • Features Of Android KitKat
    1) The new Phone (Dialer) app is now linked online with Google Maps. This means if your type Big Bazaar in Phone app (Not Search) and if tha...
  • Different Operating System and Their RAM Support
    Windows 8 64 bit Enterprise  Professional : 512 GB Windows 8 64 bit :128 GB Windows 8 32 bit : 4 GB Windows 7 64 bit Ultimate, Enterprise ...
  • C Program Library files(Header Files)
    1. <stdio.h>: input and output  function in program. 2. <conio.h>: to clear screen and  pause information function. 3. <ctype...
  • Free Download E-DRAW MAX
    link 1 : http://hotfile.com/dl/ 254163134/8de2252/EDM.rar.html
  • How To Protect Your Computer From Keyloggers
    A keylogger is a small program that stores each keystroke a user types on a specific computer's keyboard. It is capable to send log file...
  • GTU Paper Solution and Material as Per GTU syllabus
    Go to this website and download the Study material of GTU Syllabus. http://gtu-paper.blogspot.com/
  • How to read the barcodes???
    Trick to read the barcodes The first 3 digits of the barcode is the country code wherein the product was made. CODE COUNTRY 00-13 USA & ...
  • How to Hackers Erase Tracks After Hacking
    Whenever someone comes in contact with another person, place, or thing, something of that person is left behind. This means that the attacke...
  • Windiows 8 RUN Commands
    Useful windows RUN Commands 1. Accessibility Controls – access.cpl 2. Accessibility Wizard – accwiz 3. Add Hardware Wizard – hdwwiz.cpl 4. A...

Categories

  • Android
  • Android Apps
  • apps
  • BlackBerry
  • Cprog
  • dfd
  • erd
  • Facebook
  • general
  • Hacking
  • HTC
  • ios
  • java
  • Mobile
  • nokia
  • Samsung
  • Srs
  • Window Apps
  • Windows 8

Blog Archive

  • ▼  2013 (91)
    • ▼  November (6)
      • GTU Paper Solution and Material as Per GTU syllabus
      • Different Operating System and Their RAM Support
      • Free Download E-DRAW MAX
      • Play HIGH GRAPHIC GAMES like-GTA on your PC withou...
      • C Program Library files(Header Files)
      • Features Of Android KitKat
    • ►  October (5)
    • ►  September (17)
    • ►  August (3)
    • ►  July (8)
    • ►  June (13)
    • ►  May (12)
    • ►  April (27)
Powered by Blogger.

About Me

Unknown
View my complete profile