Example #1
0
  public TestFrame() {
    super("Control Window");
    setLayout(new BorderLayout());
    setSize(400, 300);
    setLocation(500, 10);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    panel = new JPanel();
    getContentPane().add(panel, BorderLayout.NORTH);
    makeSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeSHButtonActionPerformed(e);
          }
        });
    panel.add(makeSHButton);

    JButton graphButton = new JButton("morph");
    graphButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            graphButtonActionPerformed(evt);
          }
        });
    panel.add(graphButton);

    pushAllSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            pushAllSHButtonActionPerformed(e);
          }
        });
    panel.add(pushAllSHButton);

    makeRelationsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeRelationsButtonActionPerformed(e);
          }
        });
    panel.add(makeRelationsButton);

    panel.setPreferredSize(new java.awt.Dimension(20, 80));
    panel.setBorder(new LineBorder(Color.black));
    JFrame frame = new JFrame("Relationship Frame");
    frame.setSize(500, 500);
    frame.setLocation(10, 10);
    frame.getContentPane().add(testPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
Example #2
0
 public void makeSHButtonActionPerformed(ActionEvent evt) {
   String name = "Stakeholder " + (this.stakeholders.size());
   boolean a, b, c, d, e;
   a = b = c = d = e = false;
   int random = (int) (Math.random() * 32);
   System.out.println(random);
   if (random >= 16) {
     a = true;
     random -= 16;
   }
   if (random >= 8) {
     b = true;
     random -= 8;
   }
   if (random >= 4) {
     c = true;
     random -= 4;
   }
   if (random >= 2) {
     d = true;
     random -= 2;
   }
   if (random >= 1) {
     e = true;
     random -= 1;
   }
   System.out.printf("Stakeholder(%s, ,%b,%b,%b,%b,%b)%n", name, a, b, c, d, e);
   Stakeholder s = new Stakeholder(name, "", a, b, c, d, e);
   stakeholders.add(s);
   pushAllSHButton.setText("Push " + stakeholders.size() + " to View");
 }