コード例 #1
0
 private void cancelButtonActionPerformed(ActionEvent e) {
   cont.remove(this);
   cont.setCurrent(previous);
   cont.add(cont.getCurrent());
   cont.revalidate();
   cont.repaint();
 }
コード例 #2
0
ファイル: Container.java プロジェクト: trytoflys/rs377d
 /**
  * Transfers an item from one container to another.
  *
  * @param from The container to transfer from.
  * @param to The container to transfer to.
  * @param fromSlot The slot in the original container.
  * @param id The item id.
  * @return A flag indicating if the transfer was successful.
  */
 public static boolean transfer(Container from, Container to, int fromSlot, int id) {
   Item fromItem = from.get(fromSlot);
   if (fromItem == null || fromItem.getId() != id) {
     System.out.println("item not found");
     return false;
   }
   if (to.add(fromItem)) {
     from.set(fromSlot, null);
     return true;
   } else {
     System.out.println("can't add");
     return false;
   }
 }
コード例 #3
0
 private void saveButtonActionPerformed(ActionEvent e) {
   String animal = animalField.getText();
   String color = colorField.getText();
   String name = nameField.getText();
   try {
     facade.addNewTrial(animal, color, name);
   } catch (Exception ex) {
     showError();
     ex.printStackTrace();
     return;
   }
   cont.remove(this);
   cont.setCurrent(previous);
   cont.add(cont.getCurrent());
   cont.revalidate();
   cont.repaint();
 }
コード例 #4
0
 // Methode zum Umfüllen in einen anderen Behälter
 public void transfer(Container con) {
   // Füllstand wird auf den Rückgabewert der 'add'-Methode gesetzt (siehe unten)
   fill = con.add(fill);
 }