创建一个球员类,并且该类最多只允许创建十一个对象。提示利用 static 和 封装性来完成。 [必做题]

活力赛事呈现 2025-10-26 19:39:10

写雨.0:

package Dem1;

import java.awt.*;

import javax.swing.*;

public class Text {

public static void main(String[] args) {

wr q=new wr("容器和颜色的设置",250,150,3,false);

}

}

class wr extends JFrame{

wr(){}

wr(String ti,int w,int e,int we,boolean q){

super(ti);

JPanel jp1=new JPanel();

JPanel jp2=new JPanel();

JPanel jp3=new JPanel();

JButton j1=new JButton("确定");

JButton j2=new JButton("取消");

JButton j3=new JButton("中止");

JButton j4=new JButton("忽略");

JButton j5=new JButton("重试");

JButton j6=new JButton("退出");

jp1.setBackground(Color.MAGENTA);

jp2.setBackground(Color.RED);

jp3.setBackground(Color.GREEN);

j1.setBackground(Color.yellow);

j2.setBackground(Color.GREEN);

j3.setBackground(Color.MAGENTA);

j4.setBackground(Color.pink);

j5.setBackground(Color.WHITE);

j6.setBackground(Color.cyan);

Container container = this.getContentPane();

container.setLayout( new BorderLayout());

container.add(jp1,BorderLayout.NORTH);

container.add(jp2,BorderLayout.CENTER);

container.add(jp3,BorderLayout.SOUTH);

jp1.add(j1);

jp1.add(j2);

jp2.add(j3);

jp2.add(j4);

jp3.add(j5);

jp3.add(j6);

setResizable(q);

setSize(w,e);

setLocationRelativeTo(null);

setDefaultCloseOperation(we);

setVisible(true);

}

}