
正文
java点名系统代码 java随机点名器的代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
java点名系统源代码
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class test {
static String[] arr;
static boolean flag=true;
static ListString a;
static JTextField jtf;
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame frame=new JFrame();
frame.setLayout(new GridLayout(1,2));
JButton button = new JButton("抽奖");
jtf = new JTextField();
frame.add(jtf);
frame.add(button);
a = new ArrayListString();
arr = new String[]{"张三","李四","王五"};
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
int i=0;
fond:
while(true){
String str = arr[(int)(Math.random()*arr.length)];
for(String b:a){
if(b.equals(str)){
if(i=arr.length){
jtf.setText("没有人了");
break fond;
}
continue fond;
}
i++;
}
a.add(str);
jtf.setText(str);
break;
}
}
});
frame.setSize(500, 500);
frame.setLocation(500, 500);
frame.setVisible(true);
}
}
相关问答
Q1: JAVA点名系统中我在myelipise中背景图片没有把页面遮住,但是打包后页面全部被图片遮住
不是这段代码,你写的兼容性不好。
背景标签,可以直接加载,这样显示友好。
Q2: 随机点名系统 java
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class test_random extends JFrame implements ActionListener{
public static void main(String[] args) {
test_random t = new test_random();
t.init();
}
public void init(){
initListDate();
but = new JButton("开始点名");
but.setBounds(100,150,100,40);
but.addActionListener(this);
label = new JLabel("随机点名");
label.setBounds(60,20,300,40);
label.setFont(new Font("楷体",Font.BOLD,40));
show = new JLabel("");
show.setBounds(110,80,200,30);
show.setFont(new Font("楷体",Font.BOLD,30));
reset = new JButton("重新点名");
reset.setBounds(203,246,90,25);
reset.addActionListener(this);
add(but);
add(label);
add(show);
add(reset);
setLayout(null);
setVisible(true);
setResizable(false);
setBounds(100,100,300,300);
setTitle("点名");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void initListDate(){
//在这个地方添加姓名就可以java点名系统代码了
list.add("刘天廷");
list.add("孔老二");
list.add("张三");
list.add("李四");
list.add("王五");
list.add("麻六");
list.add("冯七");
list.add("京八");
list.add("茅台九");
}
public void actionPerformed(ActionEvent e) {
/*确保每人选一次*/
Object obj = e.getSource();
if(obj == but){
if(list.size()==0){
JOptionPane.showMessageDialog(null,"没有人java点名系统代码了java点名系统代码!");
return ;
}else{
Random ran = new Random();
int num = ran.nextInt(list.size());
show.setText(list.get(num));
list.remove(num);
}
}
if(obj == reset){
show.setText("");
initListDate();
}
}
private JButton but ;
private JLabel label;
private JLabel show;
private JButton reset;
private ListString list = new ArrayListString();
}
Q3: 利用java swing的学生点名系统
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
不可以根据你条件完成。
Q4: java问题请教:下面的程序我明明都在菜单中添加了菜单项,为啥只有最后一个菜单出来菜单项,前面的都没有
这是我写的一个图形界面,事件响应还没写,一个空壳子,你看看把
package indexFrame;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.text.DateFormat;
import java.util.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import java.awt.event.*;
public class IndexFrameOfSystem extends JFrame implements ActionListener {
public void launchFrame()
{
setFrameImage();
setFrameJMenu();
setFrameWindow();
this.setTitle("Student's call System");
this.setSize(450,600);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void setFrameImage()
{
ImageIcon icon =new ImageIcon("src/image/Title.jpg");//换左上角图标
this.setIconImage(icon.getImage());
}
public void setFrameJMenu()
{
mb.add(menuFile);
mb.add(menuWindow); //各自添加组件
mb.add(menuHelp);
menuFile.add(menuItemImport);
menuFile.add(menuItemExit);
menuWindow.add(menuItemshowclassInformation);
menuHelp.add(menuItemabout);
this.setJMenuBar(mb);
}
JMenuBar mb=new JMenuBar(); //菜单项的创建
JMenu menuFile=new JMenu("文件");
JMenuItem menuItemImport=new JMenuItem("导入名单");
JMenuItem menuItemExit=new JMenuItem("退出");
JMenu menuWindow =new JMenu("窗口");
JMenuItem menuItemshowclassInformation=new JMenuItem("显示班级信息");
JMenu menuHelp=new JMenu("帮助");
JMenuItem menuItemabout=new JMenuItem("关于");
public void setFrameWindow()
{
this.setLayout(null);
title.setBounds(0,0,450,20);
this.add(title);
classdianmingButton.setBounds(40,40,100,50);
this.add(classdianmingButton);
classtiwenButton.setBounds(280,40,100,50);
this.add(classtiwenButton);
txTextArea.setEditable(false);//不能在上面打字
txTextArea.setBounds(40,120,280,150);
this.add(txTextArea);
xiyiweiButton.setBounds(330,130,80,50);
this.add(xiyiweiButton);
zhantingButton.setBounds(330,210,80,50);
this.add(zhantingButton);
quexiButton.setBounds(40,280,80,30);
bGroup.add(quexiButton);
qingjiaButton.setBounds(150,280,80,30);
bGroup.add(qingjiaButton);
zaotuiButton.setBounds(260,280,80,30);
bGroup.add(zaotuiButton);
this.add(quexiButton);
this.add(qingjiaButton);
this.add(zaotuiButton);
txtArea.setEditable(false);
txtField.setBounds(40,320,280,150);//注意添加坐标的是滚动面板,而不是JTextArea
this.add( txtField);
baochunJButton.setBounds(330,480,100,40);
this.add(baochunJButton);
menuItemImport.addActionListener(this);//监听器
classdianmingButton.addActionListener(this);
classtiwenButton.addActionListener(this);
xiyiweiButton.addActionListener(this);
zhantingButton.addActionListener(this);
quexiButton.addActionListener(this);
qingjiaButton.addActionListener(this);
zaotuiButton.addActionListener(this);
menuItemExit.addActionListener(this);
baochunJButton.addActionListener(this);
menuItemshowclassInformation.addActionListener(this);
menuItemabout.addActionListener(this);
}
JLabel title=new JLabel(" 江西农业大学点名系统");
private JButton classdianmingButton=new JButton("课堂点名");
private JButton classtiwenButton=new JButton("课堂提问");
private JTextField txTextArea=new JTextField();
private JButton xiyiweiButton=new JButton("下一位");
private JButton zhantingButton=new JButton("停止");
private JRadioButton quexiButton=new JRadioButton("缺席");
private JRadioButton qingjiaButton=new JRadioButton("请假");
private JRadioButton zaotuiButton=new JRadioButton("早退");
private ButtonGroup bGroup=new ButtonGroup();
private JTextArea txtArea=new JTextArea();
private JScrollPane txtField=new JScrollPane(txtArea);
private JButton baochunJButton=new JButton("保存名单");
public static void main(String[] args) {
// TODO Auto-generated method stub
IndexFrameOfSystem ui= new IndexFrameOfSystem();
ui.launchFrame();
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
Q5: 用java+SQL server2000写的随机点名系统(其中包括课堂点名、请假时要班主任签名)的代码
java 好久不用, 已经忘记得差不多了.
只能给提供点数据库的知识.
随机点名
那么假设你有一个 学生表, 一个班里面 30行记录 , 你需要 随机 抽 5个人出来点名。
数据库怎么 随机 抽 5个人呢?
SELECT
TOP 5
*
FROM
学生表
WHERE
班级 = 今天上课的班级
ORDER BY
newid();
至于 “请假时要班主任签名”, 这个我水平有限, 电子签名的技术没学过。
java点名系统代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java随机点名器的代码、java点名系统代码的信息别忘了在本站进行查找喔。







