Friday, September 3, 2010

Vaccine Scheduler

Vaccine scheduler is desktop based software built in java, swing and mysql that provides the utility to schedule the vaccination of vaccine for doctor’s client and send the reminders to clients before the scheduled date of vaccination. So it increases the probability of not missing a vaccine to vaccination at proper time. Hence it is useful for both doctors and clients (patient). This software has been built in such a way that you can configure vaccine schedule according to standards. In future a new vaccine may be introduced, so we have kept in mind of adding new vaccines. Hence it makes this software strongly configurable.

Interested in Vaccine Scheduler? Click here to contact us.


Core features:
1. New client registration:
Doctor can register new client (Patient), at the time of registration system generates the vaccine schedule for that client. Following screen shows the client information. Doctor is able to edit/update the client information. Searching for client also there integrated.


2. View Client Schedule Chart:
This provides the utility to track the client schedule. This screen shows the information about the vaccine scheduled for a client. Here you can track about due date, given date, Notification sent etc. And also able to set the status of client’s particular vaccine. Different color show different functionality.



3. Vaccine Configuration / setting:
Here you can add new vaccine. It gives you a benefit if a new vaccine is discovered in future, you can add that vaccine in this system.


On following screen you can add time periods on which vaccination is to be scheduled. This information is used in defining vaccine schedule description.

Following screen provides the utility add the schedule vaccine time and dose number for a particular vaccine.


4. Email Configuration:
This is the email smtp configuration for sending the reminder of vaccination to client.

Interested in Vaccine Scheduler? Click here to contact us.

This entry was originally published at Experts Support Blog

Centering a swing window on screen

In swing or AWT, if you initialize a frame or window by default its position start from the top left corner of screen. Some time it looks odd as we are intended to see the window/frame at center of screen.
To make a window centered, we all need to set the location of window to center with respect to screen size.
There are following steps to make a window centered.
1. Get the screen size
2. Set the window/frame location by calculating it with screen size and frame size.

See the following example.
centerOnScreen Method provide the functionality to make a window centered.

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
*
* @author vipin
*/
public class CenteredFrameExample {

JFrame frame;
JLabel label;
public CenteredFrameExample() {
frame = new JFrame("Centered JFrame.");
label = new JLabel();
frame.setSize(250, 150);
frame.setPreferredSize(new Dimension(250, 150));
frame.getContentPane().add(BorderLayout.CENTER, label);
centerOnScreen(frame);
frame.setVisible(true);
frame.pack();
}

public static void main(String args[]) {
CenteredFrameExample centeredFrame = new CenteredFrameExample();
String text = "<html><divstyle='font-weight:bold;color:green;padding:5px;'>This is the centered frame...</div></html>";
centeredFrame.label.setText(text);
}

/**
* Centers a window on screen.
* <p>
* @param w The window to center.
*/
public void centerOnScreen(Window w) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

w.setLocation(screenSize.width / 2 - (w.getWidth() / 2),
screenSize.height / 2 - (w.getHeight() / 2));
}
}


That's all...

This entry was originally published at Experts Support Blog

Task scheduling in java – recurring tasks and one time occurring tasks

In this blog we will learn how to schedule a timer task to run at certain time. Java provides a facility to schedule tasks as per requirement.
java.util.TimerTask instance provides a task that can be scheduled to run one time or after scheduled periodic time. We can define actions to be performed by this timer task instance. We all need to override the run method of TimerTask class.
java.util.Timer Class provides the facility to schedule a timer task to occur in future in a separate background thread. Timer.schedule() method provides the functions to performed a task for one time or a periodic time interval. You can specify the initial delay.

Examples:
Scheduling a onetime occurring and a recurring task
MyTask.java

import java.util.Timer;
import java.util.TimerTask;
public class MyTask extends TimerTask {

// override the run method to perform a scheduled task action.
public void run() {
System.out.println("Running a task.");
}
}

MyTaskScheduler.java

import java.util.*;
public class MyTaskScheduler {
public static void main(String[] args) {
MyTask task = new MyTask();
Timer timer = new Timer();
// one time occurring task with specified 2 second initial delay and after every 1 second period.
timer.schedule (task, 2000, 1000);
// Schedule a task to run after every 1 second (1000 millisecond) – recurring task
timer.schedule( task, 1000);
}
}

We can also use Timer class’ method scheduleAtFixedRate() for recurring task.

This entry was originally published at Experts Support Blog

Wednesday, August 18, 2010

Redirect standard error from console to a file

I got some useful information to share:). hope will be helpful for java developers. How to redirect standard error?
Yes - Here is the solution:
To redirect standard error (or System.err) there's a method in the System class called setErr() which takes a PrintStream instance as argument.
See the following example:

/**
* Redirects System.err and sends all data to a file stored on disk.
*
*/
public void redirectSystemErrors() {
try {
System.setErr(new PrintStream(new FileOutputStream("error_file.txt")));
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
}

That's all!!!
This entry was originally published at Experts Support Blog

Sunday, August 15, 2010

Javascript Interview Questions - Part7

What is the difference between undefined value and null value?

(i) Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null

(ii) typeof undefined variable or property returns undefined whereas typeof null value returns object


What is variable typing in JavaScript?

It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows

example

i = 10;

i = "string";

This is called variable typing


Does JavaScript have the concept level scope?

No. Javascript does not have block level scope, all the variables declared inside a function possess the same level of scope unlike c, c++, java.


What are undefined and undeclared variables?

Undeclared variables are those that are not declared in the program (do not exist at all), trying to read their values gives runtime error. But if undeclared variables are assigned then implicit declaration is done .

Undefined variables are those that are not assigned any value but are declared in the program. Trying to read such variables gives special value called undefined value.


What is === operator?

In JavaScript === is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.


How to disable an HTML object?

To disable an HTML object in JavaScript use below line of code...

document.getElementById("myObject").disabled = true;


How to create a popup warning box?

Below line will help us how to create a popup warning box in JavaScript....

alert('Warning: Please enter an integer between 0 and 100.');


How to create a confirmation box?

Below line will help us how to create a Confirmation box in JavaScript....

confirm("Do you really want to launch the missile today. HuM?");


How to create an input box?

Below line will help us how to create a Input box in JavaScript....

prompt("What is your name?");


How to reload the current page?

To reload the current web page using JavaScript use the below line of code...

window.location.reload(true);


What does break and continue statements do in JavaScript?

Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop in JavaScript.


How to create a function using function constructor?

The following example illustrates this

It creates a function called square with argument x and returns x multiplied by itself.

var square = new Function ("x","return x*x");


This entry was originally published at Experts Support Blog

Friday, August 13, 2010

Javascript Interview Questions - Part6

What's relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

What are JavaScript types?
Number, String, Boolean, Function, Object, Null, Undefined.

How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);

What does isNaN function do?
Return true if the argument is not a number.

What is negative infinity?
It's a number in JavaScript, derived by dividing negative number by zero.

What boolean operators does JavaScript support?
&&, and !

What does "1"+2+4 evaluate to?
Since 1 is a string, everything is a string, so the result is 124.

How about 2+5+"8"?
Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it's concatenation, so 78 is the result.

What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.

How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};

How do you assign object properties?
obj["age"] = 17 or obj.age = 17.

What's a way to append a value to an array?
arr[arr.length] = value;

What is this keyword?
It refers to the current object.

What does undefined value mean in JavaScript?
Undefined value means the variable used in the code doesn't exist or is not assigned any value or the property doesn't exist.

This entry was originally published at Experts Support Blog

Tuesday, August 10, 2010

Javascript Interview Questions - Part5

What is the difference between the three following scenarios:

{code type = "javascript"}
var myFunction = function()
{
var person;
person;
window.person;
}

{/code}
The first is local variable, the last two are global.

How do you create an object in JavaScript?
var person = new Object; or var person = {};

How to you assign a value to an object?
person["name"] = "dave"; or person.name = "dave";

What is the difference between object and constructor in JavaScript?
Constructor works like a class, and before using, we need to create an instance. Object can be accessed directly: no instance creation.

How do you create a local and global method in a constructor?

{code type = "javascript"}
var myClass = function()
{
var PrivatMethod = function()
{
}

this.PublicMethod = function(){

}

}

{/code}

Have you heard of Douglas Crockford?
Yes he is the "inventor" of JSON.

How do you inherit from one object to another?
var Object1 = {someProp : "some value", someOtherProperty : "some other Value"};var Object2 = {someProp2 : "some value", someOtherProperty2 : "some other Value"};Object1.prototype = new Object2;//now we can alertalert(Object1.someProp2);

What debugging tools do you use?
Firebug in Firefox (console.log(); method) and Visual Studio in IE ('debug' command inserted in javascript file)

How do you delete the last element of an array in JavaScript?
array_object_variable.pop();
The pop() method in JavaScript will delete the last element of the array. Whereas the push() method will add a new element at the start of the array.

How do you get the random number between 0 and 50?
my_js_random_number = Math.floor(Math.random() * 51);
In the similar manner you can generate random number from 0 to N, you need to pass N+1 instead of 51 in this function.

How do you redirect a page using JavaScript?
To redirect to you new page or URL in JavaScript, we can use the location object.
location = ‘newpage.html’

How do you refresh the current page using JavaScript?
To refresh the current page using a javascript function, we can use the below method:
location.reload();

This entry was originally published at Experts Support Blog