public MainScreen() { Eve.setLayout( new MigLayout( "wrap 2", "[0:0, grow 50, fill][0:0, grow 50, fill]", "[pref!][grow, fill]")); quick.addActionListener( (ActionEvent e) -> { DraftScreen draft = new DraftScreen(null, this); draft.Switch(); }); viewAll.addActionListener( (ActionEvent e) -> { called = new BrowseScreen(this); called.Switch(); }); manageTeams.addActionListener( (ActionEvent e) -> { called = new ManageScreen("team", this); called.Switch(); }); managePlayers.addActionListener( (ActionEvent e) -> { called = new ManageScreen("player", this); called.Switch(); }); teams.setBorder(BorderFactory.createLineBorder(Color.black)); players.setBorder(BorderFactory.createLineBorder(Color.black)); teamScroll.setBorder(BorderFactory.createEmptyBorder()); teamScroll.getVerticalScrollBar().setUnitIncrement(16); teamScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); playerScroll.setBorder(BorderFactory.createEmptyBorder()); playerScroll.getVerticalScrollBar().setUnitIncrement(16); playerScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); this.drawScreen(); Adam.setMinimumSize(windowSize); Adam.setLocationRelativeTo(null); Adam.setVisible(true); }
public ManageScreen(String type, Screen callerScreen) { caller = callerScreen; Eve.setLayout(new MigLayout("wrap 3", "[][grow 25][grow 75]", "[][][grow]")); this.type = type; back.addActionListener( (ActionEvent e) -> { caller.refresh(); caller.Return(); }); addB.setMargin(new Insets(0, 0, 0, 0)); addB.addActionListener( (ActionEvent e) -> { if (type.matches("player")) { new ModifyPlayerPopup(null, this, null); } else if (type.matches("team")) { called = new ModifyTeamScreen(null, this); called.Switch(); } }); view.setBorder(BorderFactory.createLineBorder(Color.black)); viewScroll.getVerticalScrollBar().setUnitIncrement(16); this.drawScreen(); }
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; } }