import javaawtBorderLayout;
import javaawtCardLayout;
import javaawtContainer;
import javaawtFont;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaxswingIcon;
import javaxswingImageIcon;
import javaxswingJButton;
import javaxswingJFrame;
import javaxswingJLabel;
import javaxswingJMenu;
import javaxswingJMenuBar;
import javaxswingJMenuItem;
import javaxswingJPanel;
import javaxswingJToolBar;
import javaxswingSwingConstants;
public class MainFrame extends JFrame implements ActionListener{
InsertPanel ip = null;
SelectPanel sp = null;
JPanel pframe;
JButton jb1,jb2,jb3;
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;
CardLayout clayout;
public MainFrame(String s){
super(s);
JMenuBar mb = new JMenuBar();
thissetJMenuBar(mb);
JMenu m1 = new JMenu("系统");
JMenu m2 = new JMenu("基本信息");
JMenu m3 = new JMenu("成绩");
JMenu m4 = new JMenu("奖惩");
mbadd(m1);
mbadd(m2);
mbadd(m3);
mbadd(m4);
jm11 = new JMenuItem("退出系统");
jm21 = new JMenuItem("输入");
jm22 = new JMenuItem("查询");
jm23 = new JMenuItem("更改");
jm31 = new JMenuItem("输入成绩");
jm32 = new JMenuItem("查询成绩");
jm41 = new JMenuItem("奖励");
jm42 = new JMenuItem("处分");
m1add(jm11);
m2add(jm21);
m2add(jm22);
m2add(jm23);
m3add(jm31);
m3add(jm32);
m4add(jm41);
m4add(jm42);
Icon i1 = new ImageIcon();
Icon i2 = new ImageIcon();
Icon i3 = new ImageIcon();
jb1 = new JButton(i1);
jb1setToolTipText("输入");
jb2 = new JButton(i2);
jb2setToolTipText("查询");
jb3 = new JButton(i3);
jb3setToolTipText("退出");
JToolBar tb = new JToolBar("系统工具");
tbadd(jb1);
tbadd(jb2);
tbadd(jb3);
add(tb,BorderLayoutNORTH);
jm11addActionListener(this);
jm21addActionListener(this);
jm22addActionListener(this);
jb1addActionListener(this);
jb2addActionListener(this);
jb3addActionListener(this);
clayout = new CardLayout();
pframe = new JPanel(clayout);
add(pframe);
JPanel mainp = new JPanel(new BorderLayout());
JLabel mainl = new JLabel("学生信息管理平台",SwingConstantsCENTER);
mainlsetFont(new Font("serif",FontBOLD,30));
mainpadd(mainl);
pframeadd(mainp,"main");
clayoutshow(pframe, "main");
}
public void actionPerformed(ActionEvent e){
if(egetSource() == jm21 || egetSource() == jb1){
if(ip == null){
ip= new InsertPanel();
pframeadd(ip,"insert");
}
clayoutshow(pframe, "insert");
thissetTitle("输入学生信息");
}
else if(egetSource() == jm22 || egetSource() == jb2){
if(sp == null){
sp= new SelectPanel();
pframeadd(sp,"select");
}
clayoutshow(pframe, "select");
thissetTitle("查询学生信息");
}
else if(egetSource() == jm11 || egetSource() == jb3){
Systemexit(0);
}
}
}
第二个:
import javaxswingJFrame;
public class MainTest {
public static void main(String [] args){
MainFrame f = new MainFrame("学生信息管理平台");
fsetSize(400,300);
fsetLocation(350,250);
fsetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
fsetVisible(true);
}
}
第二个:
import javasqlConnection;
import javasqlDriverManager;
public class MySQLConnection {
static Connection getCon(){
Connection con = null;
try{
ClassforName("commysqljdbcDriver");
con = DriverManagergetConnection("jdbc:mysql://localhost/test","root","123");
}
catch(Exception e){
Systemoutprintln("建立数据库连接遇到异常!");
}
return con;
}
}
第四个:
import javaawtBorderLayout;
import javaawtGridLayout;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaxswingJButton;
import javaxswingJLabel;
import javaxswingJOptionPane;
import javaxswingJPanel;
import javaxswingJTextField;
import javaxswingSwingConstants;
public class SelectPanel extends JPanel implements ActionListener{
JButton jb;
JTextField jt;
JTextField jt1,jt2,jt3,jt4;
public SelectPanel(){
JLabel jl = new JLabel("请输入学号:",SwingConstantsCENTER);
jt = new JTextField();
jb = new JButton("确定");
JPanel jp1 = new JPanel(new GridLayout(1,3));
jp1add(jl);
jp1add(jt);
jp1add(jb);
JLabel j1,j2,j3,j4;
j1 = new JLabel("学号:",SwingConstantsCENTER);
j2 = new JLabel("姓名:",SwingConstantsCENTER);
j3 = new JLabel("性别:",SwingConstantsCENTER);
j4 = new JLabel("年龄:",SwingConstantsCENTER);
jt1 = new JTextField(6);
jt1setEditable(false);
jt2 = new JTextField(6);
jt2setEditable(false);
jt3 = new JTextField(6);
jt3setEditable(false);
jt4 = new JTextField(6);
jt4setEditable(false);
JPanel jp2 = new JPanel(new BorderLayout());
JPanel jp3 = new JPanel(new GridLayout(4,2));
jp2add(new JLabel(""),BorderLayoutNORTH);
jp3add(j1);
jp3add(jt1);
jp3add(j2);
jp3add(jt2);
jp3add(j3);
jp3add(jt3);
jp3add(j4);
jp3add(jt4);
jp2add(jp3);
thissetLayout(new BorderLayout());
add(jp1,BorderLayoutNORTH);
add(jp2);
jbaddActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(egetSource() == jb){
String stuNo = jtgetText()trim();
Student s = new Student();
boolean b = true;
try{
b = sselectByStuNo(stuNo);
}
catch(Exception ex){
Systemoutprintln("查询学生信息遇到异常!");
}
if(b){
jt1setText(sgetStuNo());
jt2setText(sgetName());
jt3setText(sgetGender());
int a = sgetAge();
Integer i = new Integer(a);
jt4setText(itoString());
}
else{
JOptionPaneshowMessageDialog(null, "无此学生!");
}
}
}
}
第五个:
import javaxswingJFrame;
public class SelectTest {
public static void main(String [] args){
JFrame f = new JFrame("查询学生信息");
SelectPanel p = new SelectPanel();
fadd(p);
fsetSize(400,300);
fsetLocation(300,250);
fsetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
fsetVisible(true);
}
}
第六个:
import javasqlConnection;
import javasqlResultSet;
import javasqlStatement;
public class Student {
String stuNo;
String name;
String gender;
int age;
public Student(){}
public Student(String stuNo,String name,String gender, int age){
thisstuNo = stuNo;
thisname = name;
thisgender = gender;
thisage = age;
}
public String getStuNo(){
return stuNo;
}
public void setStuNo(String stuNo){
thisstuNo = stuNo;
}
public String getName(){
return name;
}
public void setName(String name){
thisname = name;
}
public String getGender(){
return gender;
}
public void setGender(String gender){
thisgender = gender;
}
public int getAge(){
return age;
}
public void setAge(int age){
thisage = age;
}
public boolean insertStudent(){
boolean b = true;
try{
Connection con = MySQLConnectiongetCon();
Statement statement = concreateStatement();
String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")";
sql = new String(sqlgetBytes("gb2312"),"ISO8859_1");
statementexecuteUpdate(sql);
conclose();
}
catch(Exception e){
b = false;
Systemoutprintln("插入数据库遇到异常!");
}
return b;
}
public boolean selectByStuNo(String stuNo)throws Exception{
boolean b = true;
Connection con = MySQLConnectiongetCon();
Statement statement = concreateStatement();
String sql = "select from student where stuNo =" + stuNo;
ResultSet rs = statementexecuteQuery(sql);
if(rs != null && rsnext()){
String no = rsgetString(1);
thissetStuNo(no);
String n = rsgetString(2);
n = new String(ngetBytes("ISO8859_1"),"gb2312");
thissetName(n);
String g = rsgetString(3);
g = new String (ggetBytes("ISO8859_1"),"gb2312");
thissetGender(g);
thissetAge(rsgetInt(4));
b = true;
}
rsclose();
statementclose();
conclose();
return b;
}
}
数据库你自己弄吧,我没时间弄了!初学得多动手哦
以上就是关于金属力学性能参数哪里可以查到全部的内容,包括:金属力学性能参数哪里可以查到、如何下载wikipedia的数据库、在dns服务器中从ip地址到域名的解析,使用什么域等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)