Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use JDateChooser in Applet

843805Sep 26 2005 — edited Oct 27 2005
Hi,
I am using JDateChooser in an Applet. The applet loads well and display the date chooser and pop up date picker calendar well but when I click on the Pop-up Calendar the date is not selected.

It works well in the applet viewer but not in IE.

I am using JDateChooser from JCalendar packate http://www.toedter.com/en/jcalendar/

This is a simplified code that has the same behavior as my original.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;

import javax.swing.*;
import com.toedter.calendar.JDateChooser;

public class JCalendarApplet extends Applet {

	JDateChooser chooser = new JDateChooser();
	
	JPanel panel = new JPanel();
	JLabel label = new JLabel();
	JButton button = new JButton();
	
	public JCalendarApplet()
	{		
	}
	
	public void init()
	{
		try {
			label.setText("Hello there");
			button.setText("Update");
			button.addMouseListener(new Button_Update_mouseAdapter(this));
			panel.setSize(800,800);
			panel.add(label);
			panel.add(chooser);
			panel.add(button);	
			add(panel);
			
			
		}catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	public void updateLabel(MouseEvent e)
	{
		label.setText(chooser.getDate().toString());		
	}
}

class Button_Update_mouseAdapter extends java.awt.event.MouseAdapter {
	  JCalendarApplet adaptee;

	  Button_Update_mouseAdapter(JCalendarApplet adaptee) {
	    this.adaptee = adaptee;
	  }
	  public void mouseClicked(MouseEvent e) {
	    adaptee.updateLabel(e);
	  }
}
Expected behaviour is:
1) When click on date chooser, date picker pops up
2) When click on date picker calendar to select a date date is selected
3) When click on button date is displayed from JDateChooser

Current behaviour is:
1) When click on date chooser, date picker pops up
2) When click on date picker calendar to select a date, date picker pop up screen closes and new date is not selected.
3) When click on button, previous date is displayed.

Environment:
jar files are setup and I am running it on a web-sphere server.

I would really appreciate any help. I've search the forums but could not find any clues.

Regards,
DT
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2005
Added on Sep 26 2005
3 comments
1,303 views