Ejemplo n.º 1
0
    void drawScreen() {

      teams.add(myTeams);
      teams.add(manageTeams, "growx");
      teams.add(new JSeparator(), "growx");

      for (Team team : Global.Teams) {
        JPanel thisTeam = team.teamPreview();
        JButton startTeam = new JButton("Draft!");
        startTeam.addActionListener(
            (ActionEvent e) -> {
              DraftScreen called = new DraftScreen(team, this);
              called.Switch();
            });
        thisTeam.add(startTeam, "east");
        thisTeam.setBorder(BorderFactory.createLineBorder(Color.black));
        teamsInner.add(thisTeam, "growx");
      }
      teams.add(teamScroll);

      players.add(myPlayers);
      players.add(managePlayers, "growx");
      players.add(new JSeparator());

      for (Player player : Global.Players) {
        JPanel thisPlayer = player.playerPreview();
        JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
        modify.setMargin(new Insets(0, 0, 0, 0));
        modify.addActionListener(
            (ActionEvent e) -> {
              new ModifyPlayerPopup(player, this, null);
            });
        thisPlayer.add(modify, "east");
        thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
        playersInner.add(thisPlayer, "growx");
      }
      players.add(playerScroll);

      teamDraft.add(teamDraftL, "span, center");
      teamDraft.add(teams, "grow");
      teamDraft.add(players, "grow");

      Eve.add(quick);
      Eve.add(viewAll);
      Eve.add(teamDraft, "span");

      Adam.add(Eve);
      Adam.setSize(windowSize);
    }
Ejemplo n.º 2
0
    void drawScreen() {

      Eve.add(back, "span 2");
      Eve.add(info, "spany 2, grow");
      Eve.add(addB);
      Eve.add(label);
      Eve.add(viewScroll, "span, grow");

      switch (type) {
        case "team":
          label.setText("Teams:");
          if (Global.Teams.isEmpty()) {
            view.add(new JLabel("No teams to display"));
          } else {
            for (Team team : Global.Teams) {
              JPanel thisTeam = team.teamPreview();
              JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
              modify.setMargin(new Insets(0, 0, 0, 0));
              modify.addActionListener(
                  (ActionEvent e) -> {
                    called = new ModifyTeamScreen(team, this);
                    called.Switch();
                  });
              JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
              delete.setMargin(new Insets(0, 0, 0, 0));
              delete.addActionListener(
                  (ActionEvent e) -> {
                    Object[] options = {"Yes", "No"};
                    JFrame frame = new JFrame();
                    int answer =
                        JOptionPane.showOptionDialog(
                            frame,
                            "Are you sure you would like to delete team \"" + team.name + "?\"",
                            "Confirm Delete",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            Global.QUESTIONPIC,
                            options,
                            options[1]);
                    if (answer == 0) {
                      team.delete();
                      refresh();
                    }
                  });
              thisTeam.add(delete, "east");
              thisTeam.add(modify, "east");
              thisTeam.setBorder(BorderFactory.createLineBorder(Color.black));
              view.add(thisTeam, "growx");
            }
          }
          break;
        case "player":
          label.setText("Players:");
          if (Global.Players.isEmpty()) {
            view.add(new JLabel("No players to display"));
          } else {
            for (Player player : Global.Players) {
              JPanel thisPlayer = player.playerPreview();
              JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
              modify.setMargin(new Insets(0, 0, 0, 0));
              modify.addActionListener(
                  (ActionEvent e) -> {
                    new ModifyPlayerPopup(player, this, null);
                  });
              JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
              delete.setMargin(new Insets(0, 0, 0, 0));
              delete.addActionListener(
                  (ActionEvent e) -> {
                    Object[] options = {"I didn't like him anyways...", "No"};
                    JFrame frame = new JFrame();
                    int answer =
                        JOptionPane.showOptionDialog(
                            frame,
                            "Are you sure you would like to delete \"" + player.name + "?\"",
                            "Confirm Delete",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            Global.QUESTIONPIC,
                            options,
                            options[1]);
                    if (answer == 0) {
                      player.delete();
                      refresh();
                    }
                  });
              thisPlayer.add(delete, "east");
              thisPlayer.add(modify, "east");
              thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
              view.add(thisPlayer, "growx");
            }
          }
          break;
      }
    }