标签:south string public tin one cti ext rand tran
package className;
import java.util.Random;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Color;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class RandomName {
Random rd = new Random();
JFrame rFrame=new JFrame("自己点自己TAT专用点名器");
JLabel name = new JLabel();
JButton btn = new JButton("开始点名");
String[] stuName={"宋云飞1","宋云飞2","宋云飞3","宋云飞4","宋云飞5","宋云飞6","宋云飞7"};
public void init()
{
JLabel jt= new JLabel("T15专用点名器");
name.setHorizontalAlignment(SwingConstants.CENTER);
jt.setHorizontalAlignment(SwingConstants.CENTER);
jt.setFont(new java.awt.Font("T15专用点名器",2,40));
btn.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{
String n=getRandomName();
name.setText(n);
name.setFont(new java.awt.Font(n,2,40));
name.setForeground(Color.blue); } });
Container p = this.rFrame.getContentPane();
p.setLayout(new BorderLayout(3,1));
p.add(jt,BorderLayout.NORTH);
p.add(name,BorderLayout.CENTER);
p.add(btn,BorderLayout.SOUTH);
rFrame.pack();
rFrame.setSize(320, 320);
rFrame.setVisible(true);
}
public String getRandomName()
{ int x = 0; x = rd.nextInt(stuName.length);
return stuName[x];
}
public static void main(String[] args)
{ RandomName rn=new RandomName();
rn.init();
} }
标签:south string public tin one cti ext rand tran
原文地址:http://www.cnblogs.com/yunfeioliver/p/7232157.html