my code rong

Class Main GUI
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MainGUI extends JFrame {
Team team;
private class ButtonListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e){

}
public static void main(String[] args) {
new MainGUI("Team manager").setVisible(true);
}

private final JButtonbtCreateTeam;
public MainGUI(){

setTitle("Team manager");
setSize(400,300);
getContentPane().setLayout(new BorderLayout);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

btCreateTeam= new JButton("Creat Team");
btAddOnePlayer= new JButton("Add player");
btAddRe= new JButton("Add remaining players");
btExit= new JButton ("Exit");

lablTeamName= new JLabel ("Team name: ");
lablPlayersCount= new JLabel ("Players count: ");
lablMaxTeamSize= new JLabel ("Max team size: ");

tpPanel= new JPanel();
tpPanel.setLayout(new GridLayout(1,2));
tpPanel.add(lablTeamName);
tpPanel.add(lablPlayersCount);
tpPanel.add(lablMaxTeamSize);

btnPanel= new JPanel();
btnPanel.setLayout(new GridLayout(3,3));
btnPanel.add(btCreateTeam);
btnPanel.add(btAddOnePlayer);
btnPanel.add(btAddRe);
btnPanel.add(btExit);

textArea= new JTextArea ();

@Override
public void paint (Graphics gr ){
super.paint(gr);
gr.setColor(Color.black);
gr.drawArc(500, 500, 800, 800, 100, 100);
gr.setColor(Color.red);
gr.drawOval(600, 600, 400, 400);
gr.setColor(Color.green);
gr.drawRect(200, 200, 150, 150);
}

btCreateTeam.addActionListener(new ButtonWatcher());
btAddOnePlayer.addActionListener(new ButtonWatcher());
btAddRe.addActionListener(new ButtonWatcher());
btExit.addActionListener(new ButtonWatcher());
} Container cont = getContentPane();
cont.add(tpPanel, BorderLayout.NORTH);
cont.add(textArea, BorderLayout.CENTER);
cont.add(btnPanel, BorderLayout.SOUTH);
}
public static void main(String[]args){
MainGUI test = new MainGUI();

}
}//the end of class

Class Team
import java.util.ArrayList;
import java.util.Scanner;
public class Team {

private String name;
private int count;
private int size;
private ArrayList<Player>players;

public Team(){
Scanner scan=new Scanner(System.in);
System.out.println("What is your team name?");
name=scan.nextLine();
System.out.println("How many players are in the team?");
size=scan.nextInt();
players=new ArrayList<Player>(size);
System.out.println("Do you want to build your team now (Y/N)?");
scan.nextLine();
String choice = scan.nextLine();

switch(choice){
case "Y":
case "y":

addPlayers();
break;

case "N":
case "n":
System.out.println("No Player were added.");
break;
default:
System.out.println("Do you want to build your team now (Y/N)? ");
choice = scan.nextLine();

}
}


public String getName(){
return name;
}
public intgetSize(){
return size;
}
public intgetCount(){
return count;
}
public void setName(String name){
this.name=name;
}
public void setSize(int size){
this.size=size;
}
public void setCount(int count){
this.count=count;
}


public booleanaddPlayer(Player p1){
if(count>=size){
System.out.println("Team is full, failed to add player.");
return false;
}else{
players.add(p1);
count++;
System.out.println("Player added!");
return true;
}
}


public static Player createPlayer() {
JOptionPane.showMessageDialog(null,"Enter player info");
String playerName=JOptionPane.showInputDialog(null,"Nam:");
double playerAge=Double.parseDouble(JOptionPane.showInputDialog(null,"Age:"));
int playerNumber=Integer.parseInt(JOptionPane.showInputDialog(null,"Number:"));
Player pl = new Player( playerName,playerAge,playerNumber);
return pl;
}


public void addPlayers(){
while(team.getCount()<team.getSize()){
addPlayer(Team.createPlayer());
setText("Players count: " + team.getCount());
setText(team.toString());
}

@Override
public String toString(){
String s1 = "Team "+name+" has "+count+" player(s)\n";
String s2="";
for(int i=0;i<players.size();i++){
s2 += i + 1 + "- " + players.get(i).toString()+"\n ";
}
return s1+" "+s2;
}
}


my code can you heelp me where is the proplem i knoow that program is java
thankes bady
Does this look like a Java forum to you?
i know can help me i dont know where proplem in my program
closed account (S6k9GNh0)
Go away.
Shoo, shoo!! Go away! SCAT!
Last edited on
Hi,

I know the answer to your problem, which is a very simple mistake and can be cleared with ease. But as you have no clue & common sense I will not help you.
Topic archived. No new replies allowed.