Posts

Showing posts from 2008

Capturing a Screenshot in Java (Using AWT)

Image
Taking a screen shot in Java, sounds interesting right. Suddenly, While Searching to internet I came across this. Here is the piece of code with which you can do this task: import java.awt.AWTException; import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class ScreenCapture { public static void main(String[] args) { try { Robot robot = new Robot(); //The Size of Rectangle is Similar to Screen Resolution. BufferedImage bi=robot.createScreenCapture(new Rectangle(1280,1024)); //This will write the image to this particular location ImageIO.write(bi, "jpg", new File("C:/Ashish Docs/ScreenShot.jpg")); } catch (AWTExcepti

Bridging Java and Adobe Air - Merapi

Image
How Exiciting it will be if you can call Java directly from an AIR Application? I got excited when i read first time. And I feel you will also be. So why to wait, here is the solution for it........ Merapi Merapi: A Bridge between Adobe AIR and Java Merapi is a bridge between applications written in Java and those running in and created for Adobe AIR™ (Adobe Integrated Runtime™). Merapi has been designed to run on a user's machine, along with an Adobe AIR™application and providea direct bridge between the Adobe AIR™ framework and Java, exposing the power and overall calabilities of the user's operating system, including 3rd party hardware devices. With a light weight and straightforward API, developers can leverage the OS by writing Java companion applications for their AIR™ applications. Java programs treat Merapi as a bridge to the running Adobe AIR™ application and vice-versa. How to achieve this is given below: Sending a message from ActionScript: var message : Message = ne

Finding Postions of HTML Element in a Scrollable Div

Hi Friends, Have you ever find it difficult to find the x, y coordinates value for a HTML element in side a scrollable div. Just few days back, i got this problem. where i wanted to show tool tip on a link, but since the HTML element was in a scrollable div, the positioning to tooltip was not correct. Here is the code earlier i used to find the X and Y positions: function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } This function works well when your HTML element is not within a scrollable div. B

Removing null or specific values from list in Java

Have you tried to remove null values from a List (may a ArrayList). Yesterday I was trying it out, when I had to remove null values from a List before processing it. Initially, I was trying with the simple for loop and out I was getting Still NullPointerException while processing. I tried with couple of ways, before I came to a efficient one. Lets see this with an example: Lets see what are the flaws, when u try to remove null values from a List with a for loop: List li = new ArrayList(); FileListItem fLI = new FileListItem(); fLI.setFormFileName("123"); FileListItem fLI2 = new FileListItem(); FileListItem fLI3 = new FileListItem(); FileListItem fLI4 = new FileListItem(); fLI4.setFormFileName("456"); li.add(fLI); li.add(fLI2); li.add(fLI3); li.add(fLI4); System.out.println("====this.fileList() =====" + li); for(int i = 0;i <> System.out.println("li Size ====" + li.size() + "

Holi 2008 - Better than Expected

Image
Hi Friends, This time I celebrated holi in Pune. This year it was special. Check out the photos, which will tell you about it. Thanks My frens, who were there with Me. I hope Everybody had a great fun on that day.

Its nothing but All about me.

Hi Friends, I am Ashish Kumar Mishra. I am an Indian. I born an brought up in Hisar, a district of Haryana. I did my schooling from Hisar. But Schools keep changing after every year or 2. I did my Matriculation, From Leading High School. And Intermediate from New Yashoda Public School. Then I joined degree program from Maharshi Dayanand University in Computer Applications. In my school days (Before Matriculation), I decided that i am going for a Degree in Computers and I thought a Degree in Computer Applications was a better option. After my graduation, I went to Delhi, started preparing for the Entrance of Post Graduation in Computer Application. I joined a Company in Delhi as Trainee Programmer. But my father wanted me to go for Higher Educations. Even I wanted to go for it. And I took admission in my Post Graduation Programme in Computer Application offered by Amravati University. I passed my Post Graduation in 2007. But in 5th Semester, I joined a Company called Vision System G

Sun To acquire MySQL

Image
Sun Microsystems is going to jump in the database market with the purchase of most successful open source database developer MySQL for $1 billion. This is the main center of attraction on both the websites: & With the move, announced Wednesday, Sun takes a big leap into the $15 billion database market and pits it against the likes of Microsoft, IBM and Oracle. MySQL have clients Facebook, Google, Nokia and Baidu as customers. What makes MySQL interesting to Sun. About 20 percent of MySQL deployments run on Solaris, according to Sun estimates outlined on a conference call. Seventy five percent of MySQL deployments are not on Sun hardware. That gives Sun an opportunity to bundle hardware software and services. While Sun can also distribute MySQL through its channel and OEM partnerships and create various bundles. The overarching goal is to give MySQL more “commercial appeal” and boost adoption of open source software in the enterprise. One big question is what Sun does next to build

Three Rules for Effective Exception Handling

Image
Exceptions in Java provide a consistent mechanism for identifying and responding to error conditions. Effective exception handling will make your programs more robust and easier to debug. Exceptions are a tremendous debugging aid because they help answer these three questions: • What went wrong? • Where did it go wrong? • Why did it go wrong? When exceptions are used effectively, what is answered by the type of exception thrown, where is answered by the exception stack trace, and why is answered by the exception message. If you find your exceptions aren't answering all three questions, chances are they aren't being used effectively. Three rules will help you make the best use of exceptions when debugging your programs. These rules are: be specific, throw early, and catch late. To illustrate these rules of effective exception handling, this article discusses a fictional personal finance manager called JCheckbook. JCheckbook can be used to record and track bank account activity