0
내 길고 지저분한 코드에 문제가 있습니다. (더 좋은 방법이 있다면 알려주세요.)하지만 실제 문제는 내 JOptionPane.showConfirmDialog()로 나머지를 취소하고 싶습니다. 작업 취소의 클릭 후, 여기에 내 수업은 "newDate"개체를 null로 설정하는 것이 좋습니다 취소 옵션을 클릭하면, 지금까지 그런 일이 일어나지 않아 그래서 나는 신선한 눈이 도움이 될 것 같아요.작업 취소시 문제 JOptionPane
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Object o = jComboBox1.getSelectedItem();
String st = (String) o;
Object o2 = jComboBox2.getSelectedItem();
String st2 = (String) o2;
newDate = new Dates(st, (int)jSpinner1.getValue(),
(int)jSpinner2.getValue(), st2);
switch (newDate.getDayOfWeek()) {
//Sundays
case "Sun":
if (newDate.getHour() == 11) {
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("am")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
}
break;
//Mondays, Tuesdays, Wednesdays, Thursdays
case "Mon":
case "Tue":
case "Wed":
case "Thu":
if (newDate.getHour() == 9 || newDate.getHour() == 10 ||
newDate.getHour() == 11) {//9, 10, 11 am
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("am")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
} else if (newDate.getHour() == 3 || newDate.getHour() == 4 ||
newDate.getHour() == 5|| newDate.getHour() == 6) {//3, 4, 5, 6 pm
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("pm")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
}
break;
//Fridays
case "Fri":
if (newDate.getHour() == 9 || newDate.getHour() == 10) {//9, 10
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("am")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
} else if (newDate.getHour() == 5|| newDate.getHour() == 6) {//5, 6 pm
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("pm")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
}
break;
//Saturdays
case "Sat":
if (newDate.getHour() == 9 || newDate.getHour() == 10 ||
newDate.getHour() == 11) {//9, 10, 11 am
if (newDate.getMinute() >= 0) {
if (newDate.getDayNight().equals("am")) {
int m = JOptionPane.showConfirmDialog(null, "Warning "
+ "Lessons is During Program Time!",
"Warning!", OK_CANCEL_OPTION, WARNING_MESSAGE);
if (m == 1 || m == -1) {
newDate = null;
break;
}
}
}
}
break;
default:
break;
}
dispose();
}