这可能很容易,但我找不到解决方案。
我使用下面的代码生成了两个jDatePickers(使用jdatepicker 1.3.4 jar)。
UtilDateModel model = new UtilDateModel();
Properties p = new Properties();
p.put( "text.today", "Today" );
p.put( "text.month", "Month" );
p.put( "text.year", "Year" );
JDatePanelImpl datePanel = new JDatePanelImpl( model, p );
JDatePickerImpl datePicker1 = new JDatePickerImpl( datePanel, new DateComponentFormatter() );
UtilDateModel model2 = new UtilDateModel();
Properties p2 = new Properties();
p2.put( "text.today", "Today" );
p2.put( "text.month", "Month" );
p2.put( "text.year", "Year" );
JDatePanelImpl datePanelTo = new JDatePanelImpl( model2, p2 );
JDatePickerImpl datePicker2 = new JDatePickerImpl( datePanelTo, new DateComponentFormatter() );
datePicker1.addPropertyChangeListener( new PropertyChangeListener()
{
@Override
public void propertyChange( PropertyChangeEvent arg0 )
{
//code to disable
}
} );
我想在datepicker2中禁用日期,以便它无法在datepicker1中选择日期之前选择日期。什么应该进入事件监听器?
答案 0 :(得分:0)
你可以查看这个..
datePicker2.getComponent(1).setEnabled(false);