Share on Google+Share on Google+

k murali
1 Answer(s)      7 years ago
Posted in : Java Beginners
hi sir,thanks for providing the datepicker program
but i want to create a datepicker class in my package and i want to use that datepicker class when i am want,in that type of flexibility plz provide the program sir,in my project i am using the 1 frame for total project,in that jtabbedpanes are happend,in that jtabbed pane the dailysales is a 1 tab,i am using this datepicker in more no.of programs,how to call the total program of datepicker in my tabs in more times ,plz provide sir
Thanks in advance


View Answers

April 23, 2010 at 12:54 PM

Hi Friend,

Save separately in the same package and use the following code wherever you want to call the date picker:

setText(new DatePicker(f).displayDatePicked());


class DatePicker {
JButton[] button = new JButton[49];
int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);;
JLabel l = new JLabel("",JLabel.CENTER);
String day = "";
JDialog d;
public DatePicker(JFrame parent) {
d = new JDialog();
String[] header = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
JPanel p1 = new JPanel(new GridLayout(7,7));
p1.setPreferredSize(new Dimension(430,120));
for(int x = 0; x < button.length; x++){
final int selection = x;
button[x] = new JButton();
if(x>6)button[x].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
day = button[selection].getActionCommand();
if(x < 7){
JPanel p2 = new JPanel(new GridLayout(1,3));
JButton previous = new JButton("<< Previous");
previous.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
JButton next = new JButton("Next >>");
next.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
public void setDates(){
for(int x = 7; x < button.length; x++) button[x].setText("");
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
java.util.Calendar cal = java.util.Calendar.getInstance();
int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
for(int x = 6+dayOfWeek,day = 1; day <= daysInMonth; x++,day++) button[x].setText(""+day);
d.setTitle("Date Picker");
public String displayDatePicked() {
if(day.equals("")) return day;
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
java.util.Calendar cal = java.util.Calendar.getInstance();
return sdf.format(cal.getTime());


Related Tutorials/Questions & Answers:
Hi,  Hi,what is the purpose of hash table
Hi..   what are the keywords available in simple HelloWorld program
Hi..  what are access specifier available in java
Hi,   labels = new Hashtable<Integer,JLabel>
HI.  hi,plz send me the code for me using search button bind the data from data base in dropdownlist
Hi..  null is a keyword.True/False?   hi friend, In Java true, false and null are not a Java keyword they are literals in Java. For reading in detail go through the following link The null keyword
hi....  plzz sent me d code for counting vowels in a string... gui programme
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
hi,  print("code sample");how to display all elements in 2d array usin any one loop
Hi   how to read collection obj from jsp to servlet and from jsp - jsp?   Hi Friend, Please visit the following link: Thanks
hi....  a programme which displays a combobox which contains num from 1 to 10 and calculates the factorial of dt num which user clicks
Hi  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
hi   I have connected mysql with jsp in linux and i have used JDBC connectivity but when i run the program, its not working the program is displaying
hi   'print("code sample");`class example(){ public.static.void.main(); system.out.println("this is first pro");}   class example{ public static void main(String[]args){ System.out.println("this is first pro
Hi..  diff between syntax and signature?   signature is a particular identity of a method in terms of its argument order ,type and their number e.g. void A(arguments) then here the order ,type and number of arguments
Hi  Hi All, I am new to roseindia. I want to learn struts. I do not know anything in struts. What exactly is struts and where do we use it. Please help me. Thanks in advance. Regards, Deepak
hi!  how can i write aprogram in java by using scanner when asking user to enter element user will be free to enter any type that he/she wants to to enter, like(int,double,float,String,....) thanx for answering....   Hi
Hi..  what are the steps mandatory to develop a simple java program?   To develop a Java program following steps must be followed by a Java developer : First of all the JDK (Java Development Kit) must be available
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
online multiple choice examination  hi i am developing online multiple choice examination for that i want to store questions,four options,correct answer in a xml file using jsp or java?can any one help me?   Please
hi  what is the code for printing stars as follows * * * * * * * * * *print("code sample");   Hi Friend, Try... num=4; int p = num; int q = 0; for (int i = 0; i <= num; i++) { for (int j
hi  int A[]=new int{2,5,4,1,3}; what is the error in declaration of this   Hi Friend, This is the wrong way of declaring an array. Array is always declared in the following ways: 1)int arr[]=new int[5]; 2)int arr
Hi   I need some help I've got my java code and am having difficulty to spot what errors there are is someone able to help import java.util.Scanner; public class Post { public static void main(String[] args) { Scanner sc
hi.......  i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design... for such a programme... plz help me...   Hi Friend, Try this: import java.awt.
hi!  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin"); } catch(Exception e
Hi   I have got this code but am not totally understanding what the errors. Could someone Please help. Thanks in advance! import java.util.Random; import java.util.Scanner; private static int nextInt() { public class
storing data in xml file using jsp  hi i am storing data in xml file using this when i enter data into xml file i am getting xml declaration for each specified data?can any one help me to prevent this?   <
hi   i want to develop a online bit by bit examination process as part of my project in this i am stuck at how to store multiple choice questions options and correct option for the question.this is the first project i am doing
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null