Posts

Showing posts from September 9, 2010

get System Time in java code Example

How to get System Time in java code Example. public static String getSystemTime()     {         DateFormat df = DateFormat.getTimeInstance(3);         df.setTimeZone(TimeZone.getDefault());         String sec = new String("" + df.getCalendar().get(13));         String min = new String("" + df.getCalendar().get(12));         String hr = new String("" + df.getCalendar().get(11));         if(sec.length() < 2)             sec = "0" + sec;         if(min.length() < 2)             min = "0" + min;         if(hr.length() < 2)             hr = "0" + hr;         String currentTime = hr + ":" + min + ":" + sec;         return currentTime;     }

Open color dialog box in applet java code

How to open color dialog box in applet java code. public class ColorDialog extends Dialog {     public ColorDialog(Frame p)     {         super(p, "Color Dialog", true);         OK_button = new Button("OK");         Cancel_button = new Button("Cancel");         OK_Cancel = new Panel();         init();         show();     }     public ColorDialog(Frame p, Color c)     {         super(p, "Color Dialog", true);         OK_button = new Button("OK");         Cancel_button = new Button("Cancel");         OK_Cancel = new Panel();         init();         color_panel.setCurColor(c);         show();     }     private void init()     {         setResizable(false);         setLayout(null);         color_panel = new ColorPanel();         color_panel.setLocation(0, 0);         add(color_panel);         Dimension d = color_panel.getSize();         int cp_x = d.width;         int cp_y = d.height;         

check string is number or not in java code example

  check string is number or not in java code example public boolean isStrNumber(String str){           try{               Integer.parseInt(str);           } catch(NumberFormatException nfe) {           return false;           }           return true;           }

Recent Post

Recent Posts Widget