1 19 package org.netbeans.modules.tasklist.usertasks; 20 21 import java.text.SimpleDateFormat ; 22 import java.util.Date ; 23 24 import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor; 25 26 35 public class DateSelectionPanel extends javax.swing.JPanel 36 implements EnhancedCustomPropertyEditor { 37 38 private static final long serialVersionUID = 1; 39 40 44 private SimpleDateFormat format; 45 46 47 public DateSelectionPanel() { 48 this(new Date ()); 49 } 50 51 56 public DateSelectionPanel(Date date) { 57 initComponents(); 58 jCalendar.setDate(date); 59 } 60 61 66 public Date getDate() { 67 return jCalendar.getDate(); 68 } 69 70 75 private void initComponents() { jPanel1 = new javax.swing.JPanel (); 77 jCalendar = new com.toedter.calendar.JCalendar(); 78 jLabel1 = new javax.swing.JLabel (); 79 timeFld = new javax.swing.JTextField (); 80 81 setLayout(new java.awt.BorderLayout ()); 82 83 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (11, 11, 12, 12))); 84 jPanel1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 11, 0))); 85 jPanel1.add(jCalendar); 86 87 jLabel1.setText("@"); 88 jPanel1.add(jLabel1); 89 90 timeFld.setColumns(8); 91 timeFld.setHorizontalAlignment(javax.swing.JTextField.CENTER); 92 timeFld.setInputVerifier(new javax.swing.InputVerifier () { 93 public boolean verify(javax.swing.JComponent obj) { 94 boolean ret; 95 try { 96 format.applyPattern("HH:mm:ss"); 97 format.parse(((javax.swing.JTextField )obj).getText()); 98 ret = true; 99 } catch (Exception e) { 100 ret = false; 101 } 102 return ret; 103 } 104 }); 105 jPanel1.add(timeFld); 106 107 add(jPanel1, java.awt.BorderLayout.CENTER); 108 109 } 111 private com.toedter.calendar.JCalendar jCalendar; 113 private javax.swing.JLabel jLabel1; 114 private javax.swing.JPanel jPanel1; 115 private javax.swing.JTextField timeFld; 116 118 public Object getPropertyValue() throws IllegalStateException { 120 return getDate(); 121 } 122 } 123 | Popular Tags |