
因为需要登录界面连接数据库来对相应的信息核对。
java他是一个针对于学生的信息管理系统,主要通过UI界面进行相对应的查,改 *** 作,通常是比较适合初学该系统的同学进行的一个实战。
import java.awt.*import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import javax.swing.*
public class app//类名最好大写
{
static JFrame frm =new JFrame("清扫机器人模拟界面")
static ImageIcon bg = new ImageIcon("456.jpg")//背景图片名称,相对路径
static JLabel lab=new JLabel(bg)//图片放在标签里
public static void main(String[] args) {
lab.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight())//设置图片的大小
frm.getLayeredPane().add(lab,new Integer(Integer.MIN_VALUE))//把图片设置在第二层
JPanel jp = (JPanel) frm.getContentPane()//获取最上层JPanel
jp.setOpaque(false)//设置为透明
//JPanel jp2 = new JPanel()//如果要加按钮什么的就在这个jp2里面加,不需要的话就用了
//jp2.setOpaque(false)
//frm.add(jp2)
frm.setLayout(null)
frm.setSize(1300,700)
//frm.setBackground(Color.blue)
frm.setVisible(true)
frm.addWindowListener(new WindowAdapter() {//关闭窗口的方法没写
@Override
public void windowClosing(WindowEvent e) {
frm.setVisible(false)
System.exit(0)
}
})
}
}
我的测试没有任何问题,并且保证随机题不会重复显示 。
import javax.swing.*import java.awt.*
import java.awt.event.*
import java.util.ArrayList
public class Test extends JFrame implements ActionListener {
private JPanel A
private JTextField B
private JLabel C1
private JLabel C2
private JButton C3
private JTextField D
private ArrayList<Test3> test3
private Test3 Cur
Test() {
this.test3 = new ArrayList<Test3>()
this.test3.add(new Test3("public", "公有的"))
this.test3.add(new Test3("protected", "受保护的"))
this.test3.add(new Test3("private", "私有的"))
this.Cur = Next()
this.setBounds(100, 100, 250, 180)
A = new JPanel()
C1 = new JLabel(this.Cur.Text)
C2 = new JLabel("请输入关键字")
B = new JTextField(5)
C3 = new JButton("确定")
C3.addActionListener(this)
A.add(C1)
A.add(C2)
A.add(C3)
A.add(B)
this.add(A)
this.setVisible(true)
}
public Test3 Next() {
if (test3.size() < 1)
return null
int c = (int) (Math.random() * (test3.size()))
Test3 t = test3.get(c)
test3.remove(c)
return t
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == C3) {
if(this.Cur==null)
{
JOptionPane.showMessageDialog(this, "结束")
return
}
if (B.getText().equals(this.Cur.Key)) {
//this.setVisible(false)
JOptionPane.showMessageDialog(this, "正确")
this.Cur = Next()
if(this.Cur==null)
{
JOptionPane.showMessageDialog(this, "结束")
return
}
C1.setText(this.Cur.Text)
} else {
JOptionPane.showMessageDialog(this, "错误")
}
}
}
public static void main(String[] args) {
new Test()
}
}
class Test2 extends JFrame {
Test2() {
this.setBounds(10, 10, 200, 10)
this.setTitle("回答正确")
this.setAlwaysOnTop(true)
this.setVisible(true)
}
}
class Test3 {
public String Key
public String Text
public Test3(String key, String text) {
super()
Key = key
Text = text
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)