📄 attempnewpanel.java
字号:
label_1_3_1_1_1_1.setBounds(150, 180, 200, 20);
panel.add(label_1_3_1_1_1_1);
anyMonthSelectDay = new JRadioButton();
anyMonthSelectDay.setSelected(true);
anyMonthSelectDay.setEnabled(false);
anyMonthSelectDay.setFont(new Font("", Font.PLAIN, 12));
monthGroup.add(anyMonthSelectDay);
anyMonthSelectDay.setText("这个月的");
anyMonthSelectDay.setBounds(80, 129, 85, 20);
panel.add(anyMonthSelectDay);
anyMonthSelectWeek = new JRadioButton();
anyMonthSelectWeek.setEnabled(false);
anyMonthSelectWeek.setFont(new Font("", Font.PLAIN, 12));
monthGroup.add(anyMonthSelectWeek);
anyMonthSelectWeek.setText("这个月的");
anyMonthSelectWeek.setBounds(81, 152, 80, 20);
panel.add(anyMonthSelectWeek);
final JLabel label_1_3_1_2 = new JLabel();
label_1_3_1_2.setFont(new Font("", Font.PLAIN, 12));
label_1_3_1_2.setText("天");
label_1_3_1_2.setBounds(225, 129, 20, 20);
panel.add(label_1_3_1_2);
anyDayOfMonthJI = new JSpinner(new SpinnerNumberModel(1, 1, 31, 1));
anyDayOfMonthJI.setEnabled(false);
anyDayOfMonthJI.setFont(new Font("", Font.PLAIN, 12));
anyDayOfMonthJI.setBounds(185, 129, 40, 20);
panel.add(anyDayOfMonthJI);
final JLabel label_1_3_3 = new JLabel();
label_1_3_3.setFont(new Font("", Font.PLAIN, 12));
label_1_3_3.setHorizontalAlignment(SwingConstants.TRAILING);
label_1_3_3.setText("第");
label_1_3_3.setBounds(165, 129, 20, 20);
panel.add(label_1_3_3);
anyWeekOfMonthJI = new JComboBox(Constant.weekOfMonth);
anyWeekOfMonthJI.setEnabled(false);
anyWeekOfMonthJI.setFont(new Font("", Font.PLAIN, 12));
anyWeekOfMonthJI.setBounds(161, 152, 85, 20);
panel.add(anyWeekOfMonthJI);
anyDayOfWeekJI = new JComboBox(Constant.dayOfWeek);
anyDayOfWeekJI.setEnabled(false);
anyDayOfWeekJI.setFont(new Font("", Font.PLAIN, 12));
anyDayOfWeekJI.setBounds(249, 153, 70, 20);
panel.add(anyDayOfWeekJI);
anyWeekLabel = new JLabel();
anyWeekLabel.setFont(new Font("", Font.PLAIN, 12));
anyWeekLabel.setBounds(60, 90, 500, 20);
panel.add(anyWeekLabel);
anyMonthLabel = new JLabel();
anyMonthLabel.setFont(new Font("", Font.PLAIN, 12));
anyMonthLabel.setBounds(60, 200, 500, 20);
panel.add(anyMonthLabel);
final JLabel label_2 = new JLabel();
label_2.setFont(new Font("", Font.PLAIN, 12));
label_2.setHorizontalAlignment(SwingConstants.CENTER);
label_2.setBounds(0, 25, 65, 25);
content.add(label_2);
label_2.setText("调度类型");
final JSeparator separator_3 = new JSeparator();
separator_3.setFont(new Font("", Font.PLAIN, 12));
separator_3.setBounds(65, 38, 500, 2);
content.add(separator_3);
final JLabel label_1_3_3_1 = new JLabel();
label_1_3_3_1.setHorizontalAlignment(SwingConstants.TRAILING);
label_1_3_3_1.setFont(new Font("Dialog", Font.PLAIN, 12));
label_1_3_3_1.setText("每");
label_1_3_3_1.setBounds(26, 235, 20, 20);
panel.add(label_1_3_3_1);
hourOrMinuteJI = new JSpinner(new SpinnerNumberModel(1, 1, 60, 1));
hourOrMinuteJI.setFont(new Font("Dialog", Font.PLAIN, 12));
hourOrMinuteJI.setBounds(51, 235, 40, 20);
panel.add(hourOrMinuteJI);
hourOrMinute = new JComboBox(new String[]{"分钟", "小时"});
hourOrMinute.setFont(new Font("Dialog", Font.PLAIN, 12));
hourOrMinute.setBounds(96, 235, 60, 20);
panel.add(hourOrMinute);
label_1_3_1_1_1_2 = new JLabel();
label_1_3_1_1_1_2.setHorizontalAlignment(SwingConstants.CENTER);
label_1_3_1_1_1_2.setFont(new Font("Dialog", Font.PLAIN, 12));
label_1_3_1_1_1_2.setText("运行一次,直到");
label_1_3_1_1_1_2.setBounds(160, 235, 100, 20);
panel.add(label_1_3_1_1_1_2);
execDate = new JTextField();
execDate.setText(Common.getDateString(now.getTime(), "yyyy-MM-dd"));
execDate.setEditable(false);
execDate.setBounds(150, 70, 80, 20);
content.add(execDate);
startDate = new JTextField();
startDate.setText(Common.getDateString(now.getTime(), "yyyy-MM-dd"));
startDate.setEditable(false);
startDate.setBounds(80, 300, 80, 20);
panel.add(startDate);
endDate = new JTextField();
endDate.setText(Common.getDateString(now.getTime(), "yyyy-MM-dd"));
endDate.setEditable(false);
endDate.setBounds(290, 300, 80, 20);
panel.add(endDate);
runDateButton = new DateChooserJButton(this, execDate);
runDateButton.setEnabled(false);
runDateButton.setText("...");
runDateButton.setBounds(230, 70, 20, 20);
content.add(runDateButton);
startDateButton = new DateChooserJButton(this, startDate);
startDateButton.setText("...");
startDateButton.setBounds(160, 300, 20, 20);
panel.add(startDateButton);
endDateButton = new DateChooserJButton(this, endDate);
endDateButton.setEnabled(false);
endDateButton.setText("...");
endDateButton.setBounds(370, 300, 20, 20);
panel.add(endDateButton);
final JLabel label_1_1_1 = new JLabel();
label_1_1_1.setHorizontalAlignment(SwingConstants.TRAILING);
label_1_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
label_1_1_1.setText("开始时间");
label_1_1_1.setBounds(10, 320, 65, 20);
panel.add(label_1_1_1);
startHour = new JSpinner(new SpinnerNumberModel(now.get(Calendar.HOUR_OF_DAY), 0, 23, 1));
startHour.setValue(now.get(Calendar.HOUR_OF_DAY));
startHour.setFont(new Font("Dialog", Font.PLAIN, 12));
startHour.setBounds(80, 320, 40, 20);
panel.add(startHour);
final JLabel anyDayTIAN_1_1 = new JLabel();
anyDayTIAN_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_1_1.setText("时");
anyDayTIAN_1_1.setBounds(120, 320, 20, 20);
panel.add(anyDayTIAN_1_1);
startMinute = new JSpinner(new SpinnerNumberModel(now.get(Calendar.MINUTE), 0, 59, 1));
startMinute.setValue(now.get(Calendar.MINUTE));
startMinute.setFont(new Font("Dialog", Font.PLAIN, 12));
startMinute.setBounds(140, 320, 40, 20);
panel.add(startMinute);
final JLabel anyDayTIAN_2_1 = new JLabel();
anyDayTIAN_2_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_2_1.setText("分");
anyDayTIAN_2_1.setBounds(180, 320, 20, 20);
panel.add(anyDayTIAN_2_1);
endPeriod = new JRadioButton();
endGroup.add(endPeriod);
endPeriod.setFont(new Font("Dialog", Font.PLAIN, 12));
endPeriod.setText("持续时间");
endPeriod.setBounds(260, 255, 80, 20);
panel.add(endPeriod);
endTime = new JRadioButton();
endTime.setSelected(true);
endGroup.add(endTime);
endTime.setFont(new Font("Dialog", Font.PLAIN, 12));
endTime.setText("时间");
endTime.setBounds(260, 235, 80, 20);
panel.add(endTime);
final JLabel anyDayTIAN_2_1_1 = new JLabel();
anyDayTIAN_2_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_2_1_1.setText("分");
anyDayTIAN_2_1_1.setBounds(440, 235, 20, 20);
panel.add(anyDayTIAN_2_1_1);
endMinute = new JSpinner(new SpinnerNumberModel(now.get(Calendar.MINUTE), 0, 59, 1));
endMinute.setValue(now.get(Calendar.MINUTE));
endMinute.setFont(new Font("Dialog", Font.PLAIN, 12));
endMinute.setBounds(400, 235, 40, 20);
panel.add(endMinute);
endHour = new JSpinner(new SpinnerNumberModel(now.get(Calendar.HOUR_OF_DAY), 0, 23, 1));
endHour.setFont(new Font("Dialog", Font.PLAIN, 12));
endHour.setBounds(340, 235, 40, 20);
panel.add(endHour);
final JLabel anyDayTIAN_1_1_1 = new JLabel();
anyDayTIAN_1_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_1_1_1.setText("时");
anyDayTIAN_1_1_1.setBounds(380, 235, 20, 20);
panel.add(anyDayTIAN_1_1_1);
periodHour = new JSpinner(new SpinnerNumberModel(0, 0, 23, 1));
periodHour.setEnabled(false);
periodHour.setFont(new Font("Dialog", Font.PLAIN, 12));
periodHour.setBounds(340, 255, 40, 20);
panel.add(periodHour);
final JLabel anyDayTIAN_1_1_1_1 = new JLabel();
anyDayTIAN_1_1_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_1_1_1_1.setText("小时");
anyDayTIAN_1_1_1_1.setBounds(380, 255, 40, 20);
panel.add(anyDayTIAN_1_1_1_1);
periodMinute = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
periodMinute.setEnabled(false);
periodMinute.setFont(new Font("Dialog", Font.PLAIN, 12));
periodMinute.setBounds(420, 255, 40, 20);
panel.add(periodMinute);
final JLabel anyDayTIAN_2_1_1_1 = new JLabel();
anyDayTIAN_2_1_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_2_1_1_1.setText("分钟");
anyDayTIAN_2_1_1_1.setBounds(460, 255, 40, 20);
panel.add(anyDayTIAN_2_1_1_1);
final JLabel label_1_1 = new JLabel();
label_1_1.setHorizontalAlignment(SwingConstants.TRAILING);
label_1_1.setFont(new Font("Dialog", Font.PLAIN, 12));
label_1_1.setText("时间");
label_1_1.setBounds(250, 70, 40, 20);
content.add(label_1_1);
execHour = new JSpinner(new SpinnerNumberModel(now.get(Calendar.HOUR_OF_DAY), 0, 23, 1));
execHour.setEnabled(false);
execHour.setValue(now.get(Calendar.HOUR_OF_DAY));
execHour.setFont(new Font("Dialog", Font.PLAIN, 12));
execHour.setBounds(295, 70, 40, 20);
content.add(execHour);
final JLabel anyDayTIAN_1 = new JLabel();
anyDayTIAN_1.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_1.setText("时");
anyDayTIAN_1.setBounds(335, 70, 20, 20);
content.add(anyDayTIAN_1);
execMinute = new JSpinner(new SpinnerNumberModel(now.get(Calendar.MINUTE), 0, 59, 1));
execMinute.setEnabled(false);
execMinute.setValue(now.get(Calendar.MINUTE));
execMinute.setFont(new Font("Dialog", Font.PLAIN, 12));
execMinute.setBounds(355, 70, 40, 20);
content.add(execMinute);
final JLabel anyDayTIAN_2 = new JLabel();
anyDayTIAN_2.setFont(new Font("Dialog", Font.PLAIN, 12));
anyDayTIAN_2.setText("分");
anyDayTIAN_2.setBounds(395, 70, 20, 20);
content.add(anyDayTIAN_2);
JPanel funcPanel = new JPanel();
getContentPane().add(funcPanel, BorderLayout.SOUTH);
newAttempConfirm.setBounds(21, 19, 59, 25);
newAttempConfirm.setText("确定");
funcPanel.add(newAttempConfirm);
newAttempCancel.setBounds(21, 19, 59, 25);
newAttempCancel.setText("取消");
funcPanel.add(newAttempCancel);
}
private boolean checkData() {
boolean result = false;
if (intervalCode==2 && getSelectWeeks().equals("")) {
JOptionPane.showMessageDialog(this, "请至少选择星期中的一天!");
}
else if (intervalCode==3 && getSelectMonths().equals("")) {
JOptionPane.showMessageDialog(this, "请至少选择一个月!");
}
else {
result = true;
}
return result;
}
private void addListener() {
newAttempConfirm.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (checkData()) {
String dateString =
Common.getDateString(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm");
oneAttempData = new String[31];
oneAttempData[1] = attempName.getText();
oneAttempData[2] = String.valueOf(execCode);
oneAttempData[3] = intervalType;
oneAttempData[6] = execDate.getText();
oneAttempData[7] = execHour.getValue().toString();
oneAttempData[8] = execMinute.getValue().toString();
oneAttempData[9] = String.valueOf(intervalCode);
oneAttempData[10] = anyDayJI.getValue().toString();
oneAttempData[11] = anyWeekJI.getValue().toString();
oneAttempData[12] = String.valueOf(anyMonthSelectCode);
oneAttempData[13] = anyDayOfMonthJI.getValue().toString();
oneAttempData[14] = String.valueOf(anyWeekOfMonthJI.getSelectedIndex());
oneAttempData[15] = String.valueOf(anyDayOfWeekJI.getSelectedIndex());
oneAttempData[16] = hourOrMinuteJI.getValue().toString();
oneAttempData[17] = String.valueOf(hourOrMinute.getSelectedIndex());
oneAttempData[18] = String.valueOf(endTypeCode);
oneAttempData[19] = String.valueOf(endHour.getValue());
oneAttempData[20] = String.valueOf(endMinute.getValue());
oneAttempData[21] = String.valueOf(periodHour.getValue());
oneAttempData[22] = String.valueOf(periodMinute.getValue());
oneAttempData[23] = startDate.getText();
oneAttempData[24] = String.valueOf(startHour.getValue());
oneAttempData[25] = String.valueOf(startMinute.getValue());
oneAttempData[26] = String.valueOf(endDateCode);
oneAttempData[27] = endDate.getText();
oneAttempData[28] = getSelectWeeks();
oneAttempData[29] = getSelectMonths();
oneAttempData[30] = String.valueOf(enable.isSelected());
String[] attempDataView = new String[Constant.attempData.length];
if (!editable) {
oneAttempData[0] = String.valueOf(parent.getTable().getRowCount()+1);
oneAttempData[4] = dateString;
oneAttempData[5] = "";
parent.getAttempData().add(oneAttempData);
attempDataView[0] = oneAttempData[0];
attempDataView[1] = oneAttempData[1];
if (execType == null) {
execType = "重复";
}
attempDataView[2] = execType;
attempDataView[3] = intervalType;
attempDataView[4] = oneAttempData[4];
parent.getModel().addRow(attempDataView);
parent.getTable().updateUI();
}
else {
int idx = parent.getTable().getSelectedRow();
oneAttempData[0] = idStr;
oneAttempData[4] = createDate;
oneAttempData[5] = dateString;
parent.getAttempData().set(idx, oneAttempData);
parent.getTable().setValueAt(oneAttempData[1], idx, 1);
String temp = "";
if(oneAttempData[2].equals("1")) {
temp = "自动";
}
else if(oneAttempData[2].equals("2")) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -