ArrowEditor.java

package algorithmen.umleditor;

import java.awt.*;
import javax.swing.*;

/**
 * Editor für einen Pfeil.
 */
public class ArrowEditor extends Editor {
  
  protected JTextField nameField;
  protected JComboBox typeField;
  
  public ArrowEditor(Arrow f, Frame p) {
    super(f, 280, 150, p);
  }
  
  public ArrowEditor(Arrow f, Dialog p) {
    super(f, 280, 150, p);
  }
  
  protected void update() {
    Arrow a = (Arrow) model;
    a.setName(nameField.getText());
    a.setType((ArrowType) typeField.getSelectedItem());
  }
  
  protected void buildMainPanel(JPanel mp) {
    mp.setLayout(new BoxLayout(mp, BoxLayout.Y_AXIS));
    Arrow a = (Arrow) model;
    
    // add name field
    JPanel namePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    namePanel.add(new JLabel("Name:"));
    nameField = new JTextField(a.getName(), 15);
    namePanel.add(nameField);
    mp.add(namePanel);
    
    // add access field
    JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    typePanel.add(new JLabel("Pfeiltyp:"));
    typeField = new JComboBox(ArrowType.getArrowTypes());
    typeField.setSelectedItem(a.getType());
    typePanel.add(typeField);
    mp.add(typePanel);  
  }
}