?? studentin.java
字號:
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class studentin {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
jframe frame = new jframe();
}
}
class frameSearch extends JFrame{
Button buttonSearch ,buttonCancel;
TextField tfid1, tfid2;
frameSearch(){
super("學生信息查詢");
setLayout(null);
setLocation(100, 200);
setVisible(true);
setSize(400,400);
getContentPane().setBackground(Color.magenta);
Label ib1 = new Label("姓名 :");
Label ib2 = new Label("學號 :");
buttonSearch = new Button("查詢");
buttonCancel = new Button("退出");
tfid1 = new TextField();
tfid2 = new TextField();
ib1.setBounds(30, 170, 40, 20);
ib2.setBounds(30, 210, 40, 20);
tfid1.setBounds(80, 170, 200, 20);
tfid2.setBounds(80, 210, 200, 20);
buttonSearch.setBounds(80, 50, 80, 30);
buttonCancel.setBounds(180, 50, 80,30);
add(ib1);
add(ib2);
add(tfid1);
add(tfid2);
add(buttonSearch);
add(buttonCancel);
}
}
class frameJoin extends JFrame{
Button buttonJoin , buttonCancel ;
TextField tfid1, tfid2;
frameJoin(){
super("學生信息添加");
setLayout(null);
setLocation(100, 200);
setSize(400,400);
setVisible(true);
getContentPane().setBackground(Color.magenta);
Label ib1 = new Label("姓名 :");
Label ib2 = new Label("學號 :");
buttonJoin = new Button("添加");
buttonCancel = new Button("退出");
tfid1 = new TextField();
tfid2 = new TextField();
ib1.setBounds(30, 170, 40, 20);
ib2.setBounds(30, 210, 40, 20);
tfid1.setBounds(80, 170, 200, 20);
tfid2.setBounds(80, 210, 200, 20);
buttonJoin.setBounds(80, 50, 80, 30);
buttonCancel.setBounds(180, 50, 80,30);
add(ib1);
add(ib2);
add(tfid1);
add(tfid2);
add(buttonJoin);
add(buttonCancel);
}
}
class frameDelete extends JFrame{
Button buttonDelete,buttonCancel ;
TextField tfid1, tfid2;
frameDelete(){
super("學生信息刪除");
setLayout(null);
setLocation(100, 200);
setVisible(true);
setSize(400,400);
getContentPane().setBackground(Color.magenta);
Label ib1 = new Label("姓名 :");
Label ib2 = new Label("學號 :");
buttonDelete = new Button("刪除");
buttonCancel = new Button("退出");
tfid1 = new TextField();
tfid2 = new TextField();
ib1.setBounds(30, 170, 40, 20);
ib2.setBounds(30, 210, 40, 20);
tfid1.setBounds(80, 170, 200, 20);
tfid2.setBounds(80, 210, 200, 20);
buttonDelete.setBounds(80, 50, 80, 30);
buttonCancel.setBounds(180, 50, 80,30);
add(ib1);
add(ib2);
add(tfid1);
add(tfid2);
add(buttonDelete);
add(buttonCancel);
}
}
class frameChange extends JFrame{
Button buttonChange ,buttonCancel;
TextField tfid1, tfid2;
frameChange(){
super("學生信息修改");
setLayout(null);
setLocation(100, 200);
setVisible(true);
setSize(400,400);
getContentPane().setBackground(Color.magenta);
Label ib1 = new Label("姓名 :");
Label ib2 = new Label("學號 :");
buttonChange = new Button("修改");
buttonCancel = new Button("退出");
tfid1 = new TextField();
tfid2 = new TextField();
ib1.setBounds(30, 170, 40, 20);
ib2.setBounds(30, 210, 40, 20);
tfid1.setBounds(80, 170, 200, 20);
tfid2.setBounds(80, 210, 200, 20);
buttonChange.setBounds(80, 50, 80, 30);
buttonCancel.setBounds(180, 50, 80,30);
add(ib1);
add(ib2);
add(tfid1);
add(tfid2);
add(buttonChange);
add(buttonCancel);
}
}
class jframe extends JFrame implements ActionListener{
MenuBar menubar1;
Menu Menu1,Menu2,Menu3,Menu4,Menu5;
MenuItem item1,item2,item3,item4,item5;
jframe(){
super("學生信息管理系統");
setLayout(null);
setLocation(20, 50);
setSize(600,600);
setVisible(true);
getContentPane().setBackground(Color.magenta);
setBackground(Color.blue);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
menubar1 = new MenuBar();
Menu1 = new Menu("查詢");
Menu2 = new Menu("添加");
Menu3 = new Menu("修改");
Menu4 = new Menu("刪除");
Menu5 = new Menu("退出");
item1 = new MenuItem("查詢");
item2 = new MenuItem("添加");
item3 = new MenuItem("修改");
item4 = new MenuItem("刪除");
item5 = new MenuItem("退出");
Menu1.add(item1);
Menu2.add(item2);
Menu3.add(item3);
Menu4.add(item4);
Menu5.add(item5);
menubar1.add(Menu1);
menubar1.add(Menu2);
menubar1.add(Menu3);
menubar1.add(Menu4);
menubar1.add(Menu5);
setMenuBar(menubar1);
item1.addActionListener(this);
item2.addActionListener(this);
item3.addActionListener(this);
item4.addActionListener(this);
item5.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
// TODO Auto-generated method stub
if(e.getSource() == item1){
try{
frameSearch frame = new frameSearch();
}catch(Exception e1){
System.out.println(e1.toString());
}
}
if(e.getSource() == item2){
try{
frameJoin frame = new frameJoin();
}catch(Exception e1){
System.out.println(e1.toString());
}
}
if(e.getSource() == item3){
try{
frameChange frame = new frameChange();
}catch(Exception e1){
System.out.println(e1.toString());
}
}
if(e.getSource() == item4){
try{
frameDelete frame = new frameDelete();
}catch(Exception e1){
System.out.println(e1.toString());
}
}
if(e.getSource() == item5){
try{
}catch(Exception e1){
System.out.println(e1.toString());
}
System.exit(0);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -