java问题~~~~~~~~

来源:百度知道 编辑:UC知道 时间:2024/06/12 01:03:02
swing的,一个button,点一下换一个颜色,一共六个颜色,然后在这个button旁边出现一个计数的,点一下出 1,一直到 6 ,然后再从 1开始。

其实要做一个整地程序,上面只是一部分。如果有高人想得分的话,加我我把要求说一下,qq:171993893,做好了给2000分~~~

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class SwingButton implements ActionListener{
private JFrame frame = null;

private JButton button = null;

private JLabel label = null;

private static int count = 0;

public SwingButton(){
frame = new JFrame("按钮窗口");
button = new JButton("按钮");
label = new JLabel();
label.setBackground(Color.gray);
button.addActionListener(this);
frame.setLayout(new FlowLayout(FlowLayout.CENTER));
frame.add(button);
frame.add(label);
frame.setSize(200, 100);
frame.setDefaultCloseOperation(JF