private void Beenden(int endewert) { if (endewert == 1) { String[] srueck = { NamePatient.getText(), Rezeptnummer.getText(), BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00", Dauer.getText(), EndeStunde.getText() + ":" + EndeMinute.getText() + ":00", "" }; Eltern.setWerte(srueck); this.setVisible(false); this.dispose(); } if (endewert == 0) { String[] srueck = {"", "", "", "", "", ""}; Eltern.setWerte(srueck); this.setVisible(false); this.dispose(); } }
public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub if (((JComponent) arg0.getSource()).getName().equals("Ok")) { int dauer1 = Integer.parseInt((String) ((JRtaTextField) Dauer).getText()); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); int dauer3 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); if (dauer3 <= dauer2) { WerteSetzen(false); Dauer.requestFocus(); return; } if ((dauer3 - dauer2) != dauer1) { String sEnde; sEnde = ZeitFunk.MinutenZuZeit(dauer2 + dauer1); EndeStunde.setText(sEnde.split(":")[0]); EndeMinute.setText(sEnde.split(":")[1]); } dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); dauer3 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); dauer1 = dauer3 - dauer2; if (dauer1 != Integer.parseInt(Dauer.getText().trim())) { WerteSetzen(false); Dauer.requestFocus(); return; } if (dauer1 <= 0) { WerteSetzen(false); Dauer.requestFocus(); return; } Beenden(1); } if (((JComponent) arg0.getSource()).getName().equals("Abbruch")) { Beenden(0); } if (((JComponent) arg0.getSource()).getName().equals("radio1")) { //// System.out.println("Rechenart = 0"); rechenart = 0; jSplitLR.setDividerLocation(399); Dauer.requestFocus(); } if (((JComponent) arg0.getSource()).getName().equals("radio2")) { //// System.out.println("Rechenart = 1"); rechenart = 1; jSplitLR.setDividerLocation(399); Dauer.requestFocus(); } if (((JComponent) arg0.getSource()).getName().equals("radio3")) { //// System.out.println("Rechenart = 2"); rechenart = 2; jSplitLR.setDividerLocation(399); BeginnStunde.requestFocus(); } }
@Override public void focusLost(FocusEvent arg0) { // TODO Auto-generated method stub for (int i = 0; i < 1; i++) { if (((JComponent) arg0.getSource()).getName().equals("Dauer")) { if (rechenart == 0) { int dauer1 = Integer.parseInt((String) ((JRtaTextField) arg0.getSource()).getText()); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); // String sEnde = String.valueOf(); String sEnde = ZeitFunk.MinutenZuZeit(dauer1 + dauer2); EndeStunde.setText(sEnde.split(":")[0]); EndeMinute.setText(sEnde.split(":")[1]); } if (rechenart == 1) { int dauer1 = Integer.parseInt((String) ((JRtaTextField) arg0.getSource()).getText()); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); // String sEnde = String.valueOf(); String sEnde = ZeitFunk.MinutenZuZeit(dauer2 - dauer1); BeginnStunde.setText(sEnde.split(":")[0]); BeginnMinute.setText(sEnde.split(":")[1]); } break; } if (((JComponent) arg0.getSource()).getName().equals("BeginnStunde")) { // String sb = String.valueOf(); String sb = ((JRtaTextField) arg0.getSource()).getText(); if (sb.isEmpty()) { ((JRtaTextField) arg0.getSource()).requestFocus(); return; } if (sb.length() == 1) { ((JRtaTextField) arg0.getSource()).setText("0" + sb); } int dauer1 = Integer.parseInt((String) ((JRtaTextField) Dauer).getText()); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); int dauer3 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); /** ********************** */ if (rechenart == 0) { // String sEnde = String.valueOf(); String sEnde = ZeitFunk.MinutenZuZeit(dauer1 + dauer2); EndeStunde.setText(sEnde.split(":")[0]); EndeMinute.setText(sEnde.split(":")[1]); } if (rechenart == 2) { Dauer.setText(Integer.toString(dauer3 - dauer2)); } break; } if (((JComponent) arg0.getSource()).getName().equals("BeginnMinute")) { // String sb = String.valueOf(); String sb = ((JRtaTextField) arg0.getSource()).getText(); if (sb.isEmpty()) { ((JRtaTextField) arg0.getSource()).requestFocus(); return; } if (sb.length() == 1) { ((JRtaTextField) arg0.getSource()).setText("0" + sb); } int dauer1 = Integer.parseInt((String) ((JRtaTextField) Dauer).getText()); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); int dauer3 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); /** ********************** */ if (rechenart == 0) { // String sEnde = String.valueOf(); String sEnde = ZeitFunk.MinutenZuZeit(dauer1 + dauer2); EndeStunde.setText(sEnde.split(":")[0]); EndeMinute.setText(sEnde.split(":")[1]); } if (rechenart == 2) { Dauer.setText(Integer.toString(dauer3 - dauer2)); } break; } if (((JComponent) arg0.getSource()).getName().equals("EndeStunde")) { // String sb = String.valueOf(); String sb = ((JRtaTextField) arg0.getSource()).getText(); if (sb.isEmpty()) { ((JRtaTextField) arg0.getSource()).requestFocus(); return; } if (sb.length() == 1) { ((JRtaTextField) arg0.getSource()).setText("0" + sb); } // int dauer1 = Integer.valueOf( (String) ((JRtaTextField)Dauer).getText() ); int dauer1 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); int dauer3 = Integer.parseInt(Dauer.getText().trim()); if (rechenart == 2) { Dauer.setText(Integer.toString(dauer1 - dauer2)); } if (rechenart == 1) { // String sBeginn = String.valueOf(); String sBeginn = ZeitFunk.MinutenZuZeit(dauer1 - dauer3); BeginnStunde.setText(sBeginn.split(":")[0]); BeginnMinute.setText(sBeginn.split(":")[1]); } break; } if (((JComponent) arg0.getSource()).getName().equals("EndeMinute")) { // String sb = String.valueOf(); String sb = ((JRtaTextField) arg0.getSource()).getText(); if (sb.isEmpty()) { ((JRtaTextField) arg0.getSource()).requestFocus(); return; } if (sb.length() == 1) { ((JRtaTextField) arg0.getSource()).setText("0" + sb); } // int dauer1 = Integer.valueOf( (String) ((JRtaTextField)Dauer).getText() ); int dauer1 = (int) ZeitFunk.MinutenSeitMitternacht( EndeStunde.getText() + ":" + EndeMinute.getText() + ":00"); int dauer2 = (int) ZeitFunk.MinutenSeitMitternacht( BeginnStunde.getText() + ":" + BeginnMinute.getText() + ":00"); int dauer3 = Integer.parseInt(Dauer.getText().trim()); if (rechenart == 1) { String sBeginn; sBeginn = ZeitFunk.MinutenZuZeit(dauer1 - dauer3); BeginnStunde.setText(sBeginn.split(":")[0]); BeginnMinute.setText(sBeginn.split(":")[1]); } if (rechenart == 2) { Dauer.setText(Integer.toString(dauer1 - dauer2)); } dauer3 = Integer.parseInt(Dauer.getText().trim()); if ((dauer1 - dauer2) != dauer3) { WerteSetzen(false); Dauer.requestFocus(); return; } break; } } }