Thursday, October 14, 2010

My Search Tool

This is a program written in java that searches a file in the specific directory or in a Drive.... code:: //Search.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; import java.util.*; import java.io.*; class Search implements ActionListener,Runnable { JFrame mainFrame; JPanel rightPanel,mainPanel; JPanel leftPanel; JTextField tf1,tf2; JButton jb; int sw; int sh; JTable table; DefaultTableModel...

Tuesday, October 5, 2010

Pointers vs References...

Why java use references not pointers?????To get the answer of this we have to go the low level that is the memory allocation for the object....Where the Object is stored???A quick answer::an Object is stored on the heap??what is the Heap???The heap is a large block of memory that Java uses to store objects........How the things are Happening?????When a new object is created, the necessary amount of space is set aside for it in the heap. The new operator...

compilation gotcha in java6 vs java7

Compiling all the files in a folder for a java programmer is a routine job ,,so what we do we go to required directory and say javac*.java and all the java files get compiled...now suppose we are at e:\javapro and we want to compile all the java files present in f:\javapro so what we will do,,we will go to f:\javapro in the prompt ,and then we will say javac *.java....this is what what we do when we are using upto java7now from java7 we can compile all the files in the different folders form the different location....again suppose we are at e:\javapro...

Monday, October 4, 2010

Table Viewer

This is Table viewer by which you can see the records of your table in your dsn with a scrollbar provided at the bottom of the frame....Enter your DSN::Now your can see the Name of the tables present in your dsn,select the table and go....This is how you will see the recordes in your table.....Your can download this from::Downl...

Sunday, October 3, 2010

VirtualDosPrompt

This is the Virtual Dos Prompt created in java,having functionality like compiling the java files,running the class file ,seeing the directory,renaming the file or directory,and some thing more,,you can use help command to see the list of command available...... code:: import javax.swing.*; import java.awt.event.*; import java.awt.event.KeyEvent; import java.awt.*; import javax.swing.text.*; import java.awt.event.*; import java.awt.image.*; import...

Thursday, September 30, 2010

A nice site.....

Found a nice site today::www.typealyzer.comThey analyze your blog and tell you who you are. According to them, I am:ISTP - The Mechanics The independent and problem-solving type. They are especially attuned to the demands of the moment and are highly skilled at seeing and fixing what needs to be fixed. They generally prefer to think things out for themselves and often avoid inter-personal conflicts.The Mechanics enjoy working together with other...

Intelligent Catch Block

A new Feature in jdk1.7....Use just one catch instead of two unless needed.......Suppose you are writing a program that interact with SQL and do some IO,suppose your program can throw SQLException and IOException... Now you know that,you have to keep separate catch Blocks to catch the Exception thrown by the different hierarchy Classes as in our case IOException and SQL Exception...so we have to writetry{//some code that can throw IO or SQL Exception}catch(IOException e){//so some work}catch(Exception e){//do same work}as we can see we have to...

No more equals...just switch

Just remove one restriction from your mind that only the legal argument type of a switch statement is int, or any other type that can be promoted to int: byte, short, or char.Now with the jdk1.7 it can be a String also......a big overhead of using equals have been solved by sun....OverHead with equals::String cmd="your string";if(cmd.equals("dir"))showDir();else if(cmd.equals("cls"))clearScreen();else if(cmd.equals("exit"))exitFrom();elsegoToHell();a big overhead of if/else ladder and all,a lenghty code,but now leave the clumpsy else-if ladderjust...

Friday, September 24, 2010

2 power 99999

import java.math.BigInteger;class Power{public static void main(String... s){BigInteger i1=new BigInteger("2");System.out.println(i1.pow(99999));}}Downl...

Sudoku

//By Er. Minal Bansal import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class Logic { //to start with a random index y of array 1 to 9 Random ranobj=new Random(); int y=ranobj.nextInt(9); // this is final array int arr[][]=new int[9][9]; int myarray[]=new int[9]; // i,j -> indices of array arr //k -> index of arr upto which elements are not added int i=0,j=0,k=8; //flag1 is false if this element cannot be added boolean flag1=true; //elements to be added int next[]={1,2,3,4,5,6,7,8,9}; Logic() { firstRow(); fill(); } public...

Puzzle

import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Puzzle extends JFrame implements KeyListener{ static int[][] a={{11,0,7,3},{15,6,9,8},{2,10,13,1},{4,12,5,14}}; int i,j, row=3,col=3; JTextField[][] tf=new JTextField[4][4];Puzzle(){ setTitle("puzzle"); setLayout(new GridLayout(4,4));for(i=0;i<4;i++){for(j=0;j<4;j++){ tf[i][j]=new JTextField("");tf[i][j].setText(""+a[i][j]);tf[i][j].setHorizontalAlignment(JTextField.CENTER);tf[i][j].setFont(new Font("Georgia",Font.BOLD,26));tf[i][j].setBackground(Color.black);tf[i][j].setForeground(Color.white);...

Point to Point Chat Server

import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.net.*; import java.sql.*; class Client extends JFrame implements ActionListener { String name; String msg; String target=""; int index; Socket s; InputStreamReader isr; BufferedReader br; PrintWriter pw; /*login frame data*/ JFrame loginframe; JButton login,cancel1; JTextField loginid; JLabel loginlb; Icon canimg,logimg; /*chat frame data*/ JFrame chatframe; JTextArea text; JTextField datatosend; JButton send; JButton clear; JScrollPane...

MyJavap Tool

import java.lang.reflect.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class Myjavap implements ActionListener { JFrame mainFrame; JPanel upperPanel; JPanel lowerPanel; JTextField textField; JTextArea textArea; JScrollPane sp; JLabel intro; int flag=0; String mod=""; String fields=""; String superclass=""; String interfaces=""; String constructors=""; String methods=""; String finalinf=""; Myjavap() { mainFrame=new JFrame("MyjavapTool ~~~~~Milan~~~~~"); upperPanel=new JPanel(); textField=new JTextField("java.awt.Color"); intro=new...

ExplorerPlus

ExplorerPlusimport java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.tree.*;import javax.swing.tree.DefaultMutableTreeNode;import javax.swing.tree.TreeSelectionModel;import javax.swing.event.TreeSelectionEvent;import javax.swing.event.TreeSelectionListener;import java.io.*;import java.util.*;import javax.swing.table.*;import java.net.*;class MyExplorer implements TreeSelectionListener{ImageIcon def=new ImageIcon(".\\java.jpg");static JFrame frame;JLabel label;JTextField textField;JPanel upperPanel,lowerPanel,showPanel;JTable...