Kronosinhaven

Friday, April 24, 2009

JavaScript Code for Browser Dedection

var s;

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));


function x()
{
alert(is_ie);
}


Tuesday, April 21, 2009

VFD

URL url = new URL("http://kkr.in/voteforKotH.aspx?playerID=1");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));

store="";
String a = "";


while ((a = br.readLine()) != null) {
store = store + a;

}

Monday, April 20, 2009

Javascript LightBox CSS Menus and Others

http://www.1stwebdesigner.com/resources/57-free-image-gallery-slideshow-and-lightbox-solutions/


http://www.cssdrive.com/index.php/menudesigns/category/C20/P10/


http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

loading animation GIF

-------------------------------

I think it's the best website.....

http://www.ajaxload.info/

------------------------------

Sunday, April 19, 2009

Ajax Code for calling a Servlet

var req;

function toServlet()
{



url = "Test?hr="+document.getElementById('hr').value+"&min="+document.getElementById('min').value;



if(window.XMLHttpRequest) //non IE
{

req = new XMLHttpRequest();


try
{
req.open("GET",url,true);
req.onreadystatechange=modify;
}
catch(e)
{
alert("cannot connect to server");
}

req.send(null);
}

else if(window.ActiveXobject) //IE
{
req=new ActiveXobject("MicrosoftXMLHTTP");

if(req)
{
req.open("GET",url,true);
req.onreadystatechange=modify;
req.send(null);

}
}


}



the result must be write to out.println(s); in servlet

Receiving the response text from servlet.




function modify_InnerHtml()
{
if(req.readyState == 4)
{
if(req.status==200)
{

var res=req.responseText;


var value="
"+res+"
";

document.getElementById("lin").innerHTML=value;
}
}
}

Set Swing Window Look & Feel

write in main function where your base will be called.


UIManager.setLookAndFeel(new WindowsLookAndFeel());

Getting Dynamical PageContent Dynamically using URL class in JAVA

java.net.URL url=new java.net.URL("http://www.mapsofworld.com/lat_long
/"+cntry+"-lat-long.html");

java.net.HttpURLConnection con=(java.net.HttpURLConnection)url.openConnection();

con.connect();

java.io.InputStream in=con.getInputStream();


java.io.BufferedReader br=new java.io.BufferedReader(new
java.io.InputStreamReader(in));


String temp="";

while((temp=br.readLine())!=null)
{
cont+=temp+"\n";
}

System.out.println(cont);

JProgressbar

bar is the object of javax.swing.JProgressbar
---------------------------------------------


bar.setMinimum(0);
bar.setMaximum( int size ); ---------> Your Loop size.
bar.setValue(0);

your loop starts {


bar.setValue(bar.getValue()+1);
bar.setStringPainted(true);

Rectangle progressRect = bar.getBounds();
progressRect.x = 0;
progressRect.y = 0;
bar.paintImmediately( progressRect );


}
your loop ends.

Getting PDF picture using jpedal.jar

PdfDecoder ff = new PdfDecoder(true);
ff.openPdfFile( path );

BufferedImage img = ff.getPageAsImage(1); -------------> Number of page

ImageIO.write(img, "png", new File("D:/PDF/" + File Name+ ".png"));
ff.closePdfFile();

Getting PDF Information using iText.jar

String path="Your PDF Path"; // ----------> like C:\Books\Hello.pdf
String BookTitle = " ";
String Author = " ";
String Description = " ";
String Publisher = " ";
int TotalPage=0;


PdfReader reader=null;
reader = new PdfReader( path);

HashMap map = null;

map = new HashMap();
map = reader.getInfo();
int nums = reader.getNumberOfPages();



if (map.containsKey("Title")) {
BookTitle = map.get("Title").toString().trim();
}

if (map.containsKey("Author")) {
Author = map.get("Author");
}
if (map.containsKey("Subject")) {
Description = map.get("Subject");
}

TotalPage = nums;

if (map.containsKey("Producer")) {
Publisher = map.get("Producer");
}

MySQL Connection in JAVA

Connection Class for My SQL ( With Type 4 Connection )
---------------------------------------------------------


public class Conn {

java.sql.Connection con;

public Conn()
{
try{


Class.forName("com.mysql.jdbc.Driver");

String connectionUrl="jdbc:mysql://localhost/gfg?user=root&password=123";

con=java.sql.DriverManager.getConnection(connectionUrl);

}
catch(Exception ex){javax.swing.JOptionPane.showMessageDialog(null, ex.toString());}
}


}
--------------------------------------------------------

required JAR : mysql-connector-java-5.1.6-bin.jar