public class PatientSystem extends JFrame {
public static void main(String[] args) {
new PatientSystem();
}
private JPanel dateBar=new JPanel();
private void initUI() {
JComboBox<String> jcb = new JComboBox<>(getDate());
dateBar.add(jcb);
add(dateBar);
pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public PatientSystem(){
initUI();
}
/**
* 预约未来7个日期
* @return
*/
private static String[] getDate(){
String[] s=new String[7];
LocalDate l=LocalDate.now();
for (int i = 0; i < 7; i++) {
s[i]=l.plusDays(i+1).toString();
}
return s;
}
}
效果: