JAVA界面的代码:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JTextPane;
public class DesginPreview extends JFrame implements ActionListener{
JPanel panel;
JButton a1,a2,a3;
JLabel c1,c2,c3;
JRadioButton d1,d2,d3,d4;
JTextPane b1;
DesginPreview(){
panel = new JPanel();
panel.setLayout(null);
add(panel);
c1 = new JLabel();
c1.setText("Studnet Name:");//获取库中的user表中的用户name
c1.setBounds(20,30,200,20);
c1.setFont(new Font("Verdana",Font.PLAIN,15));
panel.add(c1);
c2 = new JLabel();
c2.setText("Question:");
c2.setBounds(450,30,200,20);
c2.setFont(new Font("Verdana",Font.PLAIN,15));
panel.add(c2);
c3 = new JLabel();
c3.setText("Question:");
c3.setBounds(20,90,200,20);
c3.setFont(new Font("Verdana",Font.PLAIN,15));
panel.add(c3);
b1 = new JTextPane();
b1.setBounds(98,90,600,200);
b1.setBackground(Color.WHITE);
b1.setEditable(false);
b1.setFont(new Font("Verdana",Font.PLAIN,15));
panel.add(b1);
ButtonGroup bg = new ButtonGroup();
d1 = new JRadioButton("Answer 1");
d1.setBounds(98,310,100,30);
d1.setFont(new Font("Verdana",Font.PLAIN,15));
bg.add(d1);
panel.add(d1);
d2 = new JRadioButton("Answer 2");
d2.setBounds(400,310,100,30);
d2.setFont(new Font("Verdana",Font.PLAIN,15));
bg.add(d2);
panel.add(d2);
d3 = new JRadioButton("Answer 3");
d3.setBounds(98,350,100,30);
d3.setFont(new Font("Verdana",Font.PLAIN,15));
bg.add(d3);
panel.add(d3);
d4 = new JRadioButton("Answer 4");
d4.setBounds(400,350,100,30);
d4.setFont(new Font("Verdana",Font.PLAIN,15));
bg.add(d4);
panel.add(d4);
a1 = new JButton("Save");
a1.setBounds(80,400,90,30);
panel.add(a1);
a2 = new JButton("Next");
a2.setBounds(250,400,90,30);
panel.add(a2);
a3 = new JButton("End Quiz");
a3.setBounds(500,400,90,30);
panel.add(a3);
setTitle("Design Preview");
setBounds(200,200,800,500);
setVisible(true);
a1.addActionListener(this);
a2.addActionListener(this);
a3.addActionListener(this);
}
public static void main(String[] args){
new DesginPreview();
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==a3){
this.dispose();
}
if(e.getSource()==a2){
this.dispose();
new Feedback();
}
}
public void Connection(){
try{
Class.forName("com.mysql.cj.jdbc.Driver");//MySQL版本
Connection con = DriverManager.getConnection("jdbc:mysql:"
+ "//localhost:3306/f_user?serverTimezone=UTC","root","123456");
}
catch(Exception ae){
JOptionPane.showMessageDialog(this ,ae);
}
}
}