jump to navigation

How to get the current date in java March 14, 2009

Posted by leppastar in java tips.
add a comment

import java.util.*;

public class Demo{
static String[] month = {“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”}

public static void main(String[] args){
Calendar currentDate = Calendar.getInstance();
String month_str = month[currentDate.get(Calendar.MONTH);
String day = currentDate.get(Calendar.DATE);
String year = currentDate.get(Calendar.YEAR);

System.out.println(month+” “+day+”, “+year);

}
}

How to change to Look and Feel of your java program to the user’s OS? March 1, 2009

Posted by leppastar in java tips.
add a comment

use UIManager..

UIManager.setUILookAndFeel(UIManager.getSystemLookAndFeelClassName());

//remember to surround it with try catch statements..XD

How to set the size of a frame into the user’s screensize in java? March 1, 2009

Posted by leppastar in java tips.
add a comment

use toolkit..

JFrame frame = new JFrame(“Frame”);
frame.setSize(Toolkit.getDefaultToolkit.getScreenSize());