WELCOME

WELCOME TO TECH-VILLA.

SEARCH YOUR TECHNICAL STUFF

OR

BROWSE THROUGH LABELS IN SIDEBAR

HAPPY BLOGGING.

Tuesday, December 22, 2009

Sunday, December 20, 2009

Simple calculator

Download calculator prog in java from here

http://rapidshare.com/files/323467151/calc.zip.html?killcode=1158993255968062742

Screen Capture in java

This project captures the screen and compress the captured image and then multicast it, so that all the machines connected with that multicast address can receive the captured screen.



Code :

/////////////////////ImageCanvas.java/////////////////////

import com.sun.image.codec..*;
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 ImageCanvas implements Runnable
{
public Robot robo;
byte [] dataone;
int count=0;
public BufferedImage myImage;
public InetAddress multicastAddress;
public MulticastSocket socket;
public static void main(String args[])
{
try
{
ImageCanvas img=new ImageCanvas();
new Thread(img).start();
}
catch(Exception e)
{
System.out.println("Errr in Imgcanvas "+e);
}
}
public void start()
{
}
public ImageCanvas()
{
try
{
robo=new Robot();
}
catch(Exception e)
{
System.out.println("Errr in Imgcanvas cons
"+e);
}
}
public void run()
{
for (;;)
{
try
{
myImage=robo.createScreenCapture(new
Rectangle(0,0,800,800));
//myImage=robo.createScreenCapture(new
Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
int x1=155;int y1=150;int x2=205;int
y2=185;
int red = 255;
int green = 0;
int blue = 0;
int transparency = 100;
// do the highlighting
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);
}
// draw original image to thumbnail
image
object and
// scale it to the new size on-the-fly

BufferedImage thumbImage = new BufferedImage(thumbWidth,thumbHeight,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D =
thumbImage.createGraphics();

graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHint
s.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");
multicastAddress =
InetAddress.getByName("224.5.6.7");
socket = new
MulticastSocket(6789);
DatagramPacket sendPacket=new
DatagramPacket(data,data.length,multicastAddress,6789);
socket.send(sendPacket);
}
dataone=data;
f.close();
file.delete();
}
catch(Exception e)
{
System.out.println("Errr in Imgcanvas
thread "+e);
}
}
}
}// End of ImageCanvas.java

////////////////////////////////////Test.java/////////////////
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import java.net.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

class screenCapture extends Canvas implements Runnable
{
Image image=null;
Robot robo =null;
byte buffer[]=new byte[60000];
static MediaTracker tracker;

public screenCapture ()
{
}
public void run()
{
for(; ;)
{
try
{
InetAddress
mdd=InetAddress.getByName("224.5.6.7");
MulticastSocket sck=new
MulticastSocket(6789);
sck.joinGroup(mdd);
DatagramPacket pck=new
DatagramPacket(buffer,buffer.length);
sck.receive(pck);
image =
Toolkit.getDefaultToolkit().createImage(pck.getData());

image=image.getScaledInstance(this.getWidth(),this.getHeight(),2);
tracker = new MediaTracker(this);
tracker.addImage(image,0);
}
catch(Exception e)
System.out.println("Errr in test "+e);
}
try
{
tracker.waitForID(0);
}
catch(Exception e)
{
System.out.println("Errr in tracker
"+e);
}
repaint();
} // end of for loop
}
public void paint (Graphics g)
{
try
{
g.drawImage(image,0,0,this);
}
catch(Exception e){System.out.println("Errr in paint
"+e);}
return;
}
public void update(Graphics g)
{
paint(g);
}

}

public class Test
{
public static void main(String args[])
{
JFrame fram = new JFrame();
screenCapture capture = new screenCapture();
fram.getContentPane().add(capture);
fram.setSize(510,520);
fram.setLocation(600,200);
fram.show();
new Thread(capture).start();
}
} //end of Test.java

Address book in java


Easy to keep records
first create a directory named data which should be in Bin folder of
jdk
and in that create a file
name data.dat

Here is the simple code in java


import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;

class AddressBook implements ActionListener
{

JPanel topPanel,bottomPanel;
JScrollPane scrollPane;
JFrame frame;

JMenuBar menubar = new JMenuBar(); ;
JMenu menu = new JMenu();
JMenuItem menuItem;

Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

Image img = kit.getImage("images/icon.JPG");

AddressBook()
{

frame = new JFrame("Address Book");
frame.setSize(680,200);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(screenWidth/4, screenHeight/4);
frame.setIconImage(img);
addWidgets();
frame.show();

}



public void addWidgets()

{
menubar.add(menu);

menu = new JMenu("Options");
menuItem = new JMenuItem("Add New Contact");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("Delete Contact");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("Search ");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("Sort Contacts");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("View All Contacts");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("Backup Contacts");
menu.add(menuItem);
menuItem.addActionListener(this);


menubar.add(menu);

menu = new JMenu("Help");

menuItem = new JMenuItem("Help Contents");
menu.add(menuItem);
menuItem.addActionListener(this);

menuItem = new JMenuItem("About");
menu.add(menuItem);
menuItem.addActionListener(this);

menubar.add(menu);

frame.setJMenuBar(menubar);


JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();

//Add Buttons To Bottom Panel
JButton AddNew = new JButton("Add New Contact");
JButton DeleteContact = new JButton("Delete
Contact");
JButton SearchContacts = new JButton("Search
Contacts");
JButton SortContacts = new JButton("Sort
Contacts");
JButton ViewContactList = new JButton("View All
Contacts");

JLabel label = new JLabel("SIZE = 2>Use The options below and In The Menu To Manage Contacts");

//Add Action Listeners
AddNew.addActionListener(this);
DeleteContact.addActionListener(this);
SearchContacts.addActionListener(this);
SortContacts.addActionListener(this);
ViewContactList.addActionListener(this);

topPanel.add(label);

bottomPanel.add(AddNew);
bottomPanel.add(DeleteContact);
bottomPanel.add(SearchContacts);
bottomPanel.add(SortContacts);
bottomPanel.add(ViewContactList);

frame.getContentPane().add(topPanel,
BorderLayout.NORTH);
frame.getContentPane().add(bottomPanel,
BorderLayout.SOUTH);
frame.setResizable(false);



}


public static void main(String args[])
{
AddressBook add = new AddressBook();

}


OperationHandler oh = new OperationHandler();

public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand() == "Add New Contact")
{
oh.AddNew();

}

else if(ae.getActionCommand() == "Search Contacts")
{
oh.SearchContacts();

}

else if(ae.getActionCommand() == "Sort Contacts")
{
oh.SortContacts();

}

else if(ae.getActionCommand() == "Delete Contact")
{
oh.DeleteContact();

}

else if(ae.getActionCommand() == "View All Contacts")
{

oh.ViewAllContacts();

}

else if(ae.getActionCommand() == "About")
{
JOptionPane.showMessageDialog(frame, "About
Address
Book:

Created By Ninad madhav

B.E. Electronics and communication
blog
http://www.tech-villa.blogspot.com","About Address Book",
JOptionPane.INFORMATION_MESSAGE);

}
else if(ae.getActionCommand() == "Help Contents")
{
try
{
oh.showHelp();
}
catch(IOException e)
{
}

}
else if(ae.getActionCommand() == "Backup Contacts")
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setMultiSelectionEnabled(false);

chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showSaveDialog(frame);
FileOutputStream bfout = null;
FileInputStream bfin = null;
String filename=null;

int p;

try
{
filename = chooser.getSelectedFile().getPath();
}
catch(Exception e)
{
}

try
{
bfout = new FileOutputStream(filename +
"\data.dat");
}
catch(Exception e)
{

}
try
{
bfin = new FileInputStream("data/data.dat");
}
catch(Exception e)
{

}

try
{
do
{ p = bfin.read();
if(p!=-1)
bfout.write(p);
}while(p!=-1);
}
catch(Exception e)
{

}


}

}


}


class Contact implements Serializable
{
private String FName;
private String LName;
private String Nname;
private String EMail;
private String Address;
private String PhoneNo;
private String Webpage;
private String Bday;

public void setDetails(String fname, String lname, String nname,
String email, String address, String phone, String web, String bday)
{
FName = fname;
LName = lname;
Nname = nname;
EMail = email;
Address = address;
PhoneNo = phone;
Webpage = web;
Bday = bday;
}


public String getFName()
{
return FName;
}

public String getLName()
{
return LName;
}

public String getNname()
{
return Nname;
}

public String getEMail()
{
return EMail;
}

public String getAddress()
{
return Address;
}

public String getPhoneNo()
{
return PhoneNo;
}

public String getWebpage()
{
return Webpage;
}

public String getBday()
{
return Bday;
}


}


class OperationHandler implements ListSelectionListener,
ActionListener,
Runnable
{


JFrame newFrame;
JTextField txtFirstName;
JTextField txtLastName;
JTextField txtNickname;
JTextField txtEMail;
JTextField txtAddress;
JTextField txtPhoneNo;
JTextField txtWebpage;
JTextField txtBDay;

JButton BttnSaveAdded;

Vector v = new Vector(10,3);
int i=0,k=0;

Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

Image img = kit.getImage("images/icon.JPG");

FileInputStream fis;
ObjectInputStream ois;

JList list;
DefaultListModel listModel;
ListSelectionModel listSelectionModel;

JRadioButton byfname, bylname;

Thread t;

JTable searchTable;

JTextField txtSearch;

String columnNames[] = { "First Name",
"Last Name",
"Nickname",
"E Mail Address",
"Address",
"Phone No.",
"Webpage",
"B'day"
};

Object data[][]= new Object[5][8];

OperationHandler()
{

try {
fis = new FileInputStream("data/data.dat");
ois = new ObjectInputStream(fis);
v = (Vector) ois.readObject();
ois.close();
}

catch(Exception e)
{

}

}


public void run()
{

try
{
FileOutputStream fos = new
FileOutputStream("data/data.dat");
ObjectOutputStream oos = new
ObjectOutputStream(fos);
oos.writeObject(v);
oos.flush();
oos.close();

}
catch(Exception e)
{
JOptionPane.showMessageDialog(newFrame, "Error
Opening
Data File: Could Not Save Contents.", "Error Opening Data File",
JOptionPane.INFORMATION_MESSAGE);
}

}


public void AddNew()
{
newFrame = new JFrame("Add New");
newFrame.setSize(220,250);
newFrame.setResizable(false);
newFrame.setIconImage(img);

JLabel lblFirstName = new JLabel("First Name: ");
JLabel lblLastName = new JLabel("Last Name: ");
JLabel lblNickname = new JLabel("Nickname: ");
JLabel lblEMail = new JLabel("EMail: ");
JLabel lblAddress = new JLabel("Address: ");
JLabel lblPhoneNo = new JLabel("Phone No: ");
JLabel lblWebpage = new JLabel("Webpage: ");
JLabel lblBDay = new JLabel("BDay: ");
JLabel lblEmpty1 = new JLabel("");
JLabel lblEmpty2 = new JLabel("");

txtFirstName = new JTextField(10);
txtLastName = new JTextField(10);
txtNickname = new JTextField(10);
txtEMail = new JTextField(10);
txtAddress = new JTextField(10);
txtPhoneNo = new JTextField(10);
txtWebpage = new JTextField(10);
txtBDay = new JTextField(10);

JButton BttnAdd = new JButton("Add New!");
BttnSaveAdded = new JButton("Save Added!");

BttnAdd.addActionListener(this);
BttnSaveAdded.addActionListener(this);
BttnSaveAdded.setEnabled(false);


JPanel centerPane = new JPanel();
JPanel bottomPane = new JPanel();

centerPane.add(lblFirstName);
centerPane.add(txtFirstName);
centerPane.add(lblLastName);
centerPane.add(txtLastName);
centerPane.add(lblNickname);
centerPane.add(txtNickname);
centerPane.add(lblEMail);
centerPane.add(txtEMail);
centerPane.add(lblAddress);
centerPane.add(txtAddress);
centerPane.add(lblPhoneNo);
centerPane.add(txtPhoneNo);
centerPane.add(lblWebpage);
centerPane.add(txtWebpage);
centerPane.add(lblBDay);
centerPane.add(txtBDay);
bottomPane.add(BttnAdd);
bottomPane.add(BttnSaveAdded);

centerPane.setLayout(new GridLayout(0,2));



newFrame.getContentPane().add(centerPane,BorderLayout.CENTER);

newFrame.getContentPane().add(bottomPane,BorderLayout.SOUTH);
newFrame.setLocation(screenWidth/4, screenHeight/4);
newFrame.show();

}


public void SearchContacts()
{
newFrame = new JFrame("Search Contacts");
newFrame.setSize(700,220);
newFrame.setLocation(screenWidth/4, screenHeight/4);
newFrame.setIconImage(img);
newFrame.setResizable(false);

JPanel topPane = new JPanel();
JLabel label1 = new JLabel("Search Contacts by First
Name
or Last Name or Both Spaced Via a Single Space:");
topPane.add(label1);

JPanel centerPane = new JPanel();
JLabel label2 = new JLabel("Search String:");
txtSearch = new JTextField(20);
JButton bttnSearch = new JButton("Search!");
bttnSearch.addActionListener(this);
JButton bttnCancel = new JButton("Cancel");
bttnCancel.addActionListener(this);
centerPane.add(label2);
centerPane.add(txtSearch);
centerPane.add(bttnSearch);
centerPane.add(bttnCancel);

searchTable = new JTable(data,columnNames);
JScrollPane scrollPane = new JScrollPane(searchTable);
searchTable.setPreferredScrollableViewportSize(new
Dimension(500, 90));

newFrame.getContentPane().add(scrollPane,BorderLayout.SOUTH);

newFrame.getContentPane().add(topPane,
BorderLayout.NORTH);
newFrame.getContentPane().add(centerPane,
BorderLayout.CENTER);
newFrame.show();
}


public void SortContacts()
{
newFrame = new JFrame("Sort Contacts");
newFrame.setSize(250,160);
newFrame.setLocation(screenWidth/4, screenHeight/4);
newFrame.setIconImage(img);
newFrame.setResizable(false);

byfname = new JRadioButton("By First Name");
byfname.setActionCommand("By First Name");
byfname.setSelected(true);

bylname = new JRadioButton("By Last Name");
bylname.setActionCommand("By Last Name");

ButtonGroup group = new ButtonGroup();
group.add(byfname);
group.add(bylname);

JPanel topPane = new JPanel();
JLabel label = new JLabel("Sort Contacts By:");
topPane.add(label);

JPanel pane = new JPanel(new GridLayout(0,1));
pane.add(byfname);
pane.add(bylname);

JPanel bottomPane = new JPanel();
JButton sortBttn = new JButton("Sort Contacts");
JButton cancelBttn = new JButton("Cancel");
bottomPane.add(sortBttn);
bottomPane.add(cancelBttn);
sortBttn.addActionListener(this);
cancelBttn.addActionListener(this);

newFrame.getContentPane().add(topPane,
BorderLayout.NORTH);
newFrame.getContentPane().add(pane,
BorderLayout.CENTER);
newFrame.getContentPane().add(bottomPane,
BorderLayout.SOUTH);

newFrame.show();

}


public void DeleteContact()
{
String fname, lname;
newFrame = new JFrame("Delete Contact");
newFrame.setSize(300,300);
newFrame.setLocation(screenWidth/4, screenHeight/4);
newFrame.setIconImage(img);

JPanel centerPane = new JPanel();
listModel = new DefaultListModel();

Contact contact = new Contact();

for(int l=0;l {
contact = (Contact) v.elementAt(l);

fname = contact.getFName();
lname = contact.getLName();
listModel.addElement(fname + " " + lname);

}


list = new JList(listModel);

list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(this);

JScrollPane listScrollPane = new JScrollPane(list);

JPanel topPane = new JPanel();
JLabel label = new JLabel("Current Contacts:");
topPane.add(label);

JPanel bottomPane = new JPanel();

JButton bttnDelete = new JButton("Delete Selected");
bottomPane.add(bttnDelete);
bttnDelete.addActionListener(this);

JButton bttnCancel = new JButton("Cancel");
bottomPane.add(bttnCancel);
bttnCancel.addActionListener(this);

newFrame.getContentPane().add(topPane,
BorderLayout.NORTH);
newFrame.getContentPane().add(listScrollPane,
BorderLayout.CENTER);
newFrame.getContentPane().add(bottomPane,
BorderLayout.SOUTH);

newFrame.show();

}


public void ViewAllContacts()
{

newFrame = new JFrame("All Contacts In The Address
Book");
newFrame.setSize(600,300);
newFrame.setIconImage(img);

Contact con = new Contact();


String columnNames[] = { "First Name",
"Last Name",
"Nickname",
"E Mail Address",
"Address",
"Phone No.",
"Webpage",
"B'day"
};



Object data[][]= new Object[v.size()][8];


for(int j=0;j {

con = (Contact) v.elementAt(k);

data[j][0] = con.getFName();
data[j][1] = con.getLName();
data[j][2] = con.getNname();
data[j][3] = con.getEMail();
data[j][4] = con.getAddress();
data[j][5] = con.getPhoneNo();
data[j][6] = con.getWebpage();
data[j][7] = con.getBday();

k++;

}
k=0;

JTable abtable = new JTable(data,columnNames);
JScrollPane scrollPane = new JScrollPane(abtable);
abtable.setPreferredScrollableViewportSize(new
Dimension(500, 370));

JPanel pane = new JPanel();
JLabel label = new JLabel("Contacts Currently In
The
Address Book");
pane.add(label);


newFrame.getContentPane().add(pane,BorderLayout.SOUTH);
newFrame.getContentPane().add(scrollPane,
BorderLayout.CENTER);
newFrame.setLocation(screenWidth/4,
screenHeight/4);
newFrame.show();




}

public void showHelp() throws IOException
{

String title = "Help Contents";
String data = "";
FileInputStream fishelp = null;
int i;

newFrame = new JFrame(title);
newFrame.setSize(401, 400);
newFrame.setResizable(false);
newFrame.setLocation(screenWidth/4, screenHeight/4);
newFrame.setIconImage(img);

JTextArea textArea = new JTextArea(5,20);
textArea.setLineWrap(true);
textArea.setEditable(false);

try
{
fishelp= new FileInputStream("help/help.txt");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(newFrame, "Help File
Not Found.", "Help File Not Found", JOptionPane.INFORMATION_MESSAGE);
}

do
{
i = fishelp.read();
if(i!=1)
data = data + (char) i;
} while(i!=-1);

fishelp.close();

textArea.setText(data);

JPanel bottomPane = new JPanel();
JButton button = new JButton("Ok");
bottomPane.add(button);
button.addActionListener(this);

JPanel topPane = new JPanel();
JLabel label = new JLabel(title);
topPane.add(label);

JScrollPane scrollPane = new JScrollPane(textArea);


newFrame.getContentPane().add(topPane,BorderLayout.NORTH);
newFrame.getContentPane().add(scrollPane);

newFrame.getContentPane().add(bottomPane,BorderLayout.SOUTH);

newFrame.show();


}


public void actionPerformed(ActionEvent ae)
{


if(ae.getActionCommand() == "Add New!")
{

if(txtFirstName.getText().equals("") &&
txtLastName.getText().equals("") && txtNickname.getText().equals("") &&
txtEMail.getText().equals("") && txtAddress.getText().equals("") &&
txtPhoneNo.getText().equals("") && txtWebpage.getText().equals("") &&
txtBDay.getText().equals(""))
{

JOptionPane.showMessageDialog(newFrame,
"Entries Empty! Fill in the required entries to save Contact.",
"Entries
Empty", JOptionPane.INFORMATION_MESSAGE);

}

else
{
Contact contact = new Contact();

contact.setDetails(txtFirstName.getText(),txtLastName.getText(),txtNicknam
e.getText(),txtEMail.getText(),txtAddress.getText(),txtPhoneNo.getText(),t
xtWebpage.getText(),txtBDay.getText());
v.addElement(contact);
txtFirstName.setText("");
txtLastName.setText("");
txtNickname.setText("");
txtEMail.setText("");
txtAddress.setText("");
txtPhoneNo.setText("");
txtWebpage.setText("");
txtBDay.setText("");

if(BttnSaveAdded.isEnabled() == false)
BttnSaveAdded.setEnabled(true);
}



}
else if(ae.getActionCommand() == "Save Added!")
{

saveVector();
newFrame.setVisible(false);


}
else if(ae.getActionCommand() == "Ok")
{
newFrame.setVisible(false);

}
else if(ae.getActionCommand() == "Delete Selected")
{

int index;
try
{

index = list.getSelectedIndex();

if(index==-1)
{

JOptionPane.showMessageDialog(newFrame, "Select a Contact first to
delete
it.", "Select a Contact First", JOptionPane.INFORMATION_MESSAGE);
}

else
{

int n =
JOptionPane.showConfirmDialog(newFrame, "Are you sure you want to
delete
the selected Contact?", "Are you sure?", JOptionPane.YES_NO_OPTION);


if (n == JOptionPane.YES_OPTION)
{
listModel.remove(index);
v.removeElementAt(index);
saveVector();
newFrame.show();


}
else if (n ==
JOptionPane.NO_OPTION)
{

}

}

}
catch(Exception e)
{

}

}
else if(ae.getActionCommand() == "Cancel")
{

newFrame.setVisible(false);
}
else if(ae.getActionCommand() == "Search!")
{
String SearchStr;
SearchStr = txtSearch.getText();
boolean flag=false;
Contact con = new Contact();
int c=0;

for(int t=0;t<5;t++)
{
data[t][0] = "";
data[t][1] = "";
data[t][2] = "";
data[t][3] = "";
data[t][4] = "";
data[t][5] = "";
data[t][6] = "";
data[t][7] = "";
}

for(int t=0;t {

con = (Contact) v.elementAt(t);


if(SearchStr.equalsIgnoreCase(con.getFName()) ||
SearchStr.equalsIgnoreCase(con.getLName()) ||
SearchStr.equalsIgnoreCase(con.getFName() + " " + con.getLName()))
{
flag=true;

data[c][0] = con.getFName();
data[c][1] = con.getLName();
data[c][2] = con.getNname();
data[c][3] = con.getEMail();
data[c][4] = con.getAddress();
data[c][5] = con.getPhoneNo();
data[c][6] = con.getWebpage();
data[c][7] = con.getBday();
searchTable = new
JTable(data,columnNames);
newFrame.setSize(700,221);
newFrame.setSize(700,220);

if(c<5)
c++;
}

}


if(flag)
{
JOptionPane.showMessageDialog(newFrame,
"Contact Found!", "Search Result!", JOptionPane.INFORMATION_MESSAGE);
}

else
{
JOptionPane.showMessageDialog(newFrame,
"No
Such Contact Found!", "Search Result!",
JOptionPane.INFORMATION_MESSAGE);
}


}
else if(ae.getActionCommand() == "Sort Contacts")
{

if(byfname.isSelected())
{
Contact contact1 = new Contact();
Contact contact2 = new Contact();
Contact temp = new Contact();
int l,m;

for(l=0;l {
for(m=l+1;m {
contact1 = (Contact) v.elementAt(l);
contact2 = (Contact) v.elementAt(m);


if(contact1.getFName().compareTo(contact2.getFName()) > 0)
{
temp = (Contact)
v.elementAt(m);

v.setElementAt(v.elementAt(l),m);
v.setElementAt(temp,l);
}

}
}

saveVector();
}
else
{

Contact contact1 = new Contact();
Contact contact2 = new Contact();
Contact temp = new Contact();
int l,m;

for(l=0;l {
for(m=l+1;m {
contact1 = (Contact) v.elementAt(l);
contact2 = (Contact) v.elementAt(m);


if(contact1.getLName().compareTo(contact2.getLName()) > 0)
{
temp = (Contact)
v.elementAt(m);

v.setElementAt(v.elementAt(l),m);
v.setElementAt(temp,l);
}

}
}

saveVector();
}

newFrame.setVisible(false);
}


}


public void saveVector()
{
t = new Thread(this, "Save Vector Thread");
t.start();

}


public void valueChanged(ListSelectionEvent lse)
{


}

}

Friday, December 18, 2009

How to remove Newfolder.exe virus

This virus is popularly known as regsvr.exe virus, or as new folder.exe virus and most people identify this one by looking at autorun.inf file in their pen drives, But trend micro identified it as WORM_DELF.FKZ. You all might have seen this folder in ur pen drives, many times.

New folder.exe virus


I prefer manual process simply because it gives me option to learn new things in the process.

So Get started............

  1. Cut The Supply Line
    1. Search for autorun.inf file. It is a read only file so you will have to change it to normal by right clicking the file , selecting the properties and un-check the read only option
    2. Open the file in notepad and delete everything and save the file.
    3. Now change the file status back to read only mode so that the virus could not get access again.
    4. Autorun
    5. Click start->run and type msconfig and click ok
    6. Go to startup tab look for regsvr and uncheck the option click OK.
    7. Click on Exit without Restart, cause there are still few things we need to do before we can restart the PC.
    8. Now go to control panel -> scheduled tasks, and delete the At1 task listed their.
  2. Open The Gates Of Castle
    1. Click on start -> run and type gpedit.msc and click Ok.
    2. If you are Windows XP Home Edition user you might not have gpedit.msc in that case download and install it from Windows XP Home Edition: gpedit.msc and then follow these steps.
    3. Go to users configuration->Administrative templates->system
    4. Find “prevent access to registry editing tools” and change the option to disable.
    5. Opening the gate of castle: Group Edit Policies
    6. Once you do this you have registry access back.
  3. Launch The Attack At Heart Of Castle
    1. Click on start->run and type regedit and click ok
    2. Go to edit->find and start the search for regsvr.exe,
    3. Launch the attack in the heart of castle: registry search
    4. Delete all the occurrence of regsvr.exe; remember to take a backup before deleting. KEEP IN MIND regsvr32.exe is not to be deleted. Delete regsvr.exe occurrences only.
    5. At one ore two places you will find it after explorer.exe in theses cases only delete the regsvr.exe part and not the whole part. E.g. Shell = “Explorer.exe regsvr.exe” the just delete the regsvr.exe and leave the explorer.exe
  4. Seek And Destroy the enemy soldiers, no one should be left behind
    1. Click on start->search->for files and folders.
    2. Their click all files and folders
    3. Type “*.exe” as filename to search for
    4. Click on ‘when was it modified ‘ option and select the specify date option
    5. Type from date as 1/31/2008 and also type To date as 1/31/2008
    6. Seek and destory enemy soldiers: the search option
    7. Now hit search and wait for all the exe’s to show up.
    8. Once search is over select all the exe files and shift+delete the files, caution must be taken so that you don’t delete the legitimate exe file that you have installed on 31st January.
    9. Also selecting lot of files together might make your computer unresponsive so delete them in small bunches.
    10. Also find and delete regsvr.exe, svchost .exe( notice an extra space between the svchost and .exe)
  5. Time For Celebrations
    1. Now do a cold reboot (ie press the reboot button instead) and you are done.


Guyz if this helped u bit then please reply and let me know about ur experience.
N-JOY

Saturday, December 12, 2009

Remove Surabaya virus.

Surabaya in my birthday
Don't kill me, i'm just send message from your computer
Terima kasih telah menemaniku walaupun hanya sesaat, tapi bagiku sangat berarti
Maafkan jika kebahagiaan yang kuminta adalah teman sepanjang hidupku
Seharusnya aku mengerti bahwa keberadaanku bukanlah disisimu, hanyalah lamunan dalam sesal
Untuk kekasih yang tak kan pernah kumiliki 3r1k1m0


Is it the message that displays before you log in to your systems ,Then your system has been affected by surabaya virus.

How to remove it.


First of all:-

Stop Surabaya in My Birthday Virus processes:

explorce.exe
explorcr.exe

Delete Surabaya in My Birthday Virus files:

autorun.in


Now proceed as under:-
  • First step:-
Search your hard discs for surabaya keyword. And now delete all files you get on this search

  • Second step:-
Open Task manager and go to process tab. If you find there Surabaya process then end that process.

  • Third step:-
Your Folder Option May not be working.

1)go to start>Run.
type regedit

now go to following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL
now set CheckedValue to 1.

its done.
Try this solution only when you have some knowledge about Registry.

otherwise download this file and run it.

Download http://rapidshare.com/files/302380179/NMshf.exe

  • Fourth step
To remove Message

download this tool
http://rapidshare.com/files/302380693/showmessage.exe and click remove message

OR

Go to start>run>type "regedit"

go to registry key.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

and edit the following values

"LegalNoticeCaption", "LegalNoticeText" ,delete the message saved to them.

it will look like

"LegalNoticeCaption"=""
"LegalNoticeText"=""


  • Fifth step:-
Again go to regedit ,Press ctrl+F type surabaya.
If you find any registry entry hen delete it.

Now to delete surabaya DLL files.

  1. First locate Surabaya in My Birthday Virus DLL files you want to delete. Open your Windows Start menu, then click “Run.” Type “cmd” in Run, and click “OK.”
  2. To change your current directory, type “cd” in the command box, press your “Space” key, and enter the full directory where the Surabaya in My Birthday Virus DLL file is located. If you’re not sure if the Surabaya in My Birthday Virus DLL file is located in a particular directory, enter “dir” in the command box to display a directory’s contents. To go one directory back, enter “cd ..” in the command box and press “Enter.”
  3. When you’ve located the Surabaya in My Birthday Virus DLL file you want to remove, type “regsvr32 /u SampleDLLName.dll” (e.g., “regsvr32 /u jl27script.dll”) and press your “Enter” key.

Thats it you have done.


Guys please give your comments if your PC is now working fine, using this procedure..

N-joy

Remove amvo.exe virus

This is very common virus that spreads mainly due to USBs or pendrives.

Symptoms of this virus:

  • Folder Option is not working - enable the Folder Option or show the hidden files running into you computer.
  • Drives open in new windows from My Computer
  • Low Disk Space
  • Cannot show hidden files
  • Slows down USB devices
  • Adds infections to plugged in USB devices
How to Remove this?



This is the solution on how to remove the amvo.exe and to fix the folder option problem. Just follow this steps:
  1. Uncheck amvo.exe from msconfig>> startup (type msconfig in run and click on the startup tab) also and restart your system
  1. Click Start > Run and type REGEDIT
  2. Go to HKEY_CURRENT_USER > SOFTWARE > Microsoft > Windows > CurrentVersion > Explorer > Advanced
  3. On the right side, double click the hidden value and give it a value of 1.
  4. Same for HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > Explorer > Advanced > Folder > Hidden > SHOW ALL Change the value of Checked Value to 1. OR
  5. Download this file to enable folder option
  6. Check if your Folder Option if its working now. If it works! OK you are now ready to delete the Amvo.exe virus now.

Go to your Folder Option and enable the show all the hidden files and you remove the following files if they are exist in the exact location or directory:

c:\autorun.inf
c:\u.bat
c:\amvo.exe
c:\awda2.exe
c:\d.com
c:\mvo.dll
c:\amvo1.dll
c:\windows\system32\ amvo.exe
c:\windows\system32\ awda2.exe
c:\windows\system32\ d.com
c:\windows\system32\ mvo.dll
c:\windows\system32\ amvo1.dll
c:\windows\system32\u.bat



Now go to Run and type cmd then type regedit.
Press Ctrl + F to find the files amvo.exe and delete it. After that, reboot your PC. OK that's it. Guys please your comments if your PC is working now for using this procedure..

N-JOY

Wednesday, December 2, 2009

NOTEPAD TRICKS

World Trade Centre Trick

Did you know that the flight number of the plane that had hit WTC ...on
9/11 was Q33N ....
Open your Notepad in ur computer and type the flight
number i.e Q33N...
Increase the Font Size to 72, Change the Font to Wingdings. U will be amazed by the findings
.


Simple Trick

=>Open Notepad
=> Enter four words separated by spaces, wherein the first word has 4 letters, the next two have three letters, and the last word has five letters
=> Save the file.
=>Close Notepad.
=>Reopen Notepad.





Reason:

The reason this happens:

In notepad, any other 4-3-3-5 letter word combo will have the same results.
It is all to do with a limitation in Windows. Text files containing Unicode UTF-16-encoded Unicode are supposed to start with a "Byte-Order Mark" (BOM), which is a two-byte flag that tells a reader how the following UTF-16 data is encoded.

1) You are saving to 8-bit Extended ASCII.
2) You are reading from 16-bit UNICODE .
This is why the 18 8-bit characters are being displayed as 9 (not supported by your codepage) 16-bit UNICODE characters

N-JOY.