?? sms.java
字號:
JLabel ldeleteError,lb;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
lb = new JLabel(new ImageIcon("2.jpg"));
fdeleteError = new JFrame("刪除出錯");
pdeleteError = new JPanel();
pdeleteError.setLayout(null);
ldeleteError = new JLabel("必須輸入學號!");
btsure = new JButton("確 定");
ldeleteError.setFont(h);
btsure.setFont(h);
ldeleteError.setForeground(Color.red);
btsure.setForeground(Color.blue);
pdeleteError.add(ldeleteError);
pdeleteError.add(btsure);
pdeleteError.add(lb);
fdeleteError.add(pdeleteError,"Center");
ldeleteError.setBounds(80,25,150,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fdeleteError.setLocation(530,400);
fdeleteError.setSize(300,140);
fdeleteError.setVisible(true);
fdeleteError.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
fdeleteError.dispose();
}
}
}
class DeleteNo implements ActionListener{
JFrame fdeleteno;
JPanel pdeleteno;
JLabel ldeleteno,lb;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
lb = new JLabel(new ImageIcon("2.jpg"));
fdeleteno = new JFrame("刪除不成功");
pdeleteno = new JPanel();
pdeleteno.setLayout(null);
ldeleteno = new JLabel("該學號不存在!");
btsure = new JButton("確 定");
ldeleteno.setFont(h);
btsure.setFont(h);
ldeleteno.setForeground(Color.red);
btsure.setForeground(Color.blue);
pdeleteno.add(ldeleteno);
pdeleteno.add(btsure);
pdeleteno.add(lb);
fdeleteno.add(pdeleteno,"Center");
ldeleteno.setBounds(80,25,150,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fdeleteno.setLocation(530,400);
fdeleteno.setSize(300,140);
fdeleteno.setVisible(true);
fdeleteno.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
fdeleteno.dispose();
}
}
}
class DeleteFrame_True implements ActionListener{
Font h = new Font("楷體", Font.BOLD, 18);
JFrame fdeletetrue;
JPanel pdeletetrue;
JLabel ldeletetrue,lb;
JButton btsure;
void go(){
lb = new JLabel(new ImageIcon("2.jpg"));
fdeletetrue = new JFrame("刪除結果");
pdeletetrue = new JPanel();
pdeletetrue.setLayout(null);
ldeletetrue = new JLabel("刪除成功!");
btsure = new JButton("確 定");
ldeletetrue.setFont(h);
btsure.setFont(h);
ldeletetrue.setForeground(Color.red);
btsure.setForeground(Color.blue);
pdeletetrue.add(ldeletetrue);
pdeletetrue.add(btsure);
pdeletetrue.add(lb);
fdeletetrue.add(pdeletetrue,"Center");
ldeletetrue.setBounds(100,25,120,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fdeletetrue.setLocation(530,400);
fdeletetrue.setSize(300,140);
fdeletetrue.setVisible(true);
fdeletetrue.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
fdeletetrue.dispose();
}
}
}
class ChangeSearchFrame implements ActionListener{
Font h = new Font("楷體", Font.BOLD, 18);
JFrame fchangesearch;
JPanel pchangesearch;
JLabel lbnumber,lb;
JTextField tfnumber;
JButton btsure;
void go(){
lb = new JLabel(new ImageIcon("3.jpg"));
fchangesearch = new JFrame("修改");
pchangesearch = new JPanel();
pchangesearch.setLayout(null);
lbnumber = new JLabel("學號");
tfnumber = new JTextField();
btsure = new JButton("確 定");
lbnumber.setFont(h);
btsure.setFont(h);
lbnumber.setForeground(Color.yellow);
btsure.setForeground(Color.blue);
pchangesearch.add(lbnumber);
pchangesearch.add(tfnumber);
pchangesearch.add(btsure);
pchangesearch.add(lb);
fchangesearch.add(pchangesearch,"Center");
lbnumber.setBounds(50,30,40,30);
tfnumber.setBounds(100,30,180,30);
lb.setBounds(0,0,350,160);
btsure.setBounds(200,80,100,30);
fchangesearch.setLocation(500,300);
fchangesearch.setSize(350,160);
fchangesearch.setVisible(true);
fchangesearch.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
btsure.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
if(tfnumber.getText().equals(""))
{
fchangesearch.dispose();
ChangeError changeerror = new ChangeError();
changeerror.go();
return;
}
int o=0;
for(int s=0;s<=SMS.i;s++){
if(SMS.student[s][0].toString().equals(tfnumber.getText())){
o++;
SMS.k=s;
break;
}
}
if(o==0){
fchangesearch.dispose();
ChangeNo changeno = new ChangeNo();
changeno.go();
return;
}
fchangesearch.dispose();
ChangeResultFrame changeresultframe = new ChangeResultFrame();
changeresultframe.go();
}
}
}
class ChangeError implements ActionListener{
JFrame fchangeError;
JPanel pchangeError;
JLabel lchangeError,lb;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
lb = new JLabel(new ImageIcon("2.jpg"));
fchangeError = new JFrame("修改出錯");
pchangeError = new JPanel();
pchangeError.setLayout(null);
lchangeError = new JLabel("必須輸入學號!");
btsure = new JButton("確 定");
lchangeError.setFont(h);
btsure.setFont(h);
lchangeError.setForeground(Color.red);
btsure.setForeground(Color.blue);
pchangeError.add(lchangeError);
pchangeError.add(btsure);
pchangeError.add(lb);
fchangeError.add(pchangeError,"Center");
lchangeError.setBounds(80,25,150,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fchangeError.setLocation(530,400);
fchangeError.setSize(300,140);
fchangeError.setVisible(true);
fchangeError.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
fchangeError.dispose();
}
}
}
class ChangeNo implements ActionListener{
JFrame fchangeno;
JPanel pchangeno;
JLabel lchangeno,lb;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
lb = new JLabel(new ImageIcon("2.jpg"));
fchangeno = new JFrame("修改不成功");
pchangeno = new JPanel();
pchangeno.setLayout(null);
lchangeno = new JLabel("該學號不存在!");
btsure = new JButton("確 定");
lchangeno.setFont(h);
btsure.setFont(h);
lchangeno.setForeground(Color.red);
btsure.setForeground(Color.blue);
pchangeno.add(lchangeno);
pchangeno.add(btsure);
pchangeno.add(lb);
fchangeno.add(pchangeno,"Center");
lchangeno.setBounds(80,25,150,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fchangeno.setLocation(530,400);
fchangeno.setSize(300,140);
fchangeno.setVisible(true);
fchangeno.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
fchangeno.dispose();
}
}
}
class ChangeResultFrame implements ActionListener{
JFrame fchangeresult;
JPanel pchangeresult;
JLabel lb;
JLabel lbnumber,lbname,lbsex,lbage,lbresult,lbchinese,lbmaths,lbenglish;
JTextField tfnumber,tfname,tfsex,tfage,tfchinese,tfmaths,tfenglish;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
Font q = new Font("楷體", Font.BOLD, 22);
lb = new JLabel(new ImageIcon("2.jpg"));
fchangeresult = new JFrame("修改");
pchangeresult = new JPanel();
pchangeresult.setLayout(null);
lbnumber = new JLabel("學號");
lbname = new JLabel("姓名");
lbsex = new JLabel("性別");
lbage = new JLabel("年齡");
lbresult = new JLabel("成績");
lbchinese = new JLabel("語文");
lbmaths = new JLabel("數學");
lbenglish = new JLabel("英語");
lbnumber.setFont(h);
lbname.setFont(h);
lbsex.setFont(h);
lbage.setFont(h);
lbresult.setFont(q);
lbchinese.setFont(h);
lbmaths.setFont(h);
lbenglish.setFont(h);
lbnumber.setForeground(Color.blue);
lbname.setForeground(Color.blue);
lbsex.setForeground(Color.blue);
lbage.setForeground(Color.blue);
lbresult.setForeground(Color.red);
lbchinese.setForeground(Color.red);
lbmaths.setForeground(Color.red);
lbenglish.setForeground(Color.red);
tfnumber = new JTextField();
tfname = new JTextField();
tfsex = new JTextField();
tfage = new JTextField();
tfchinese = new JTextField();
tfmaths = new JTextField();
tfenglish = new JTextField();
tfnumber.setText(SMS.student[SMS.k][0].toString());
tfname.setText(SMS.student[SMS.k][1].toString());
tfsex.setText(SMS.student[SMS.k][2].toString());
tfage.setText(SMS.student[SMS.k][3].toString());
tfchinese.setText(SMS.student[SMS.k][4].toString());
tfmaths.setText(SMS.student[SMS.k][5].toString());
tfenglish.setText(SMS.student[SMS.k][6].toString());
btsure = new JButton("確 定");
btsure.setFont(h);
btsure.setForeground(Color.blue);
pchangeresult.add(lbnumber);
pchangeresult.add(lbname);
pchangeresult.add(lbsex);
pchangeresult.add(lbage);
pchangeresult.add(lbresult);
pchangeresult.add(lbchinese);
pchangeresult.add(lbmaths);
pchangeresult.add(lbenglish);
pchangeresult.add(tfnumber);
pchangeresult.add(tfname);
pchangeresult.add(tfsex);
pchangeresult.add(tfage);
pchangeresult.add(tfchinese);
pchangeresult.add(tfmaths);
pchangeresult.add(tfenglish);
pchangeresult.add(btsure);
pchangeresult.add(lb);
fchangeresult.add(pchangeresult,"Center");
lbnumber.setBounds(15,30,40,25);
lbname.setBounds(15,85,40,25);
lbsex.setBounds(15,140,40,25);
lbage.setBounds(15,195,40,25);
lbresult.setBounds(330,30,80,25);
lbchinese.setBounds(250,85,40,25);
lbmaths.setBounds(250,140,40,25);
lbenglish.setBounds(250,195,40,25);
tfnumber.setBounds(70,30,150,25);
tfname.setBounds(70,85,150,25);
tfsex.setBounds(70,140,150,25);
tfage.setBounds(70,195,150,25);
tfchinese.setBounds(300,85,150,25);
tfmaths.setBounds(300,140,150,25);
tfenglish.setBounds(300,195,150,25);
btsure.setBounds(340,240,100,30);
lb.setBounds(0,0,500,320);
fchangeresult.setLocation(500,300);
fchangeresult.setSize(500,320);
fchangeresult.setVisible(true);
fchangeresult.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
btsure.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if((String)e.getActionCommand()=="確 定"){
if(tfnumber.getText().equals(""))
{
fchangeresult.dispose();
ChangeFalse changefalse = new ChangeFalse();
changefalse.go();
return;
}
for(int s=0;s<=SMS.i;s++){
if(s!=SMS.k&&SMS.student[s][0].toString().equals(tfnumber.getText())){
fchangeresult.dispose();
ChangeFalse1 changefalse1 = new ChangeFalse1();
changefalse1.go();
return;
}
}
StringBuffer temp;
temp = new StringBuffer(tfnumber.getText());
SMS.student[SMS.k][0] = temp;
temp = new StringBuffer(tfname.getText());
SMS.student[SMS.k][1] = temp;
temp = new StringBuffer(tfsex.getText());
SMS.student[SMS.k][2] = temp;
temp = new StringBuffer(tfage.getText());
SMS.student[SMS.k][3] = temp;
if(tfchinese.getText().equals("")){
SMS.student[SMS.k][4] = new StringBuffer("0");
}
else{
temp = new StringBuffer(tfchinese.getText());
SMS.student[SMS.k][4] = temp;
}
if(tfmaths.getText().equals("")){
SMS.student[SMS.k][5] = new StringBuffer("0");
}
else{
temp = new StringBuffer(tfmaths.getText());
SMS.student[SMS.k][5] = temp;
}
if(tfenglish.getText().equals("")){
SMS.student[SMS.k][6] = new StringBuffer("0");
}
else{
temp = new StringBuffer(tfenglish.getText());
SMS.student[SMS.k][6] = temp;
}
fchangeresult.dispose();
ChangeSearchFrame_True changesearchframe_true = new ChangeSearchFrame_True();
changesearchframe_true.go();
}
}
}
class ChangeFalse implements ActionListener{
JFrame fchangefalse;
JPanel pchangefalse;
JLabel lchangefalse,lb;
JButton btsure;
void go(){
Font h = new Font("楷體", Font.BOLD, 18);
lb = new JLabel(new ImageIcon("2.jpg"));
fchangefalse = new JFrame("修改不成功");
pchangefalse = new JPanel();
pchangefalse.setLayout(null);
lchangefalse = new JLabel("學號不能為空!");
btsure = new JButton("確 定");
lchangefalse.setFont(h);
btsure.setFont(h);
lchangefalse.setForeground(Color.red);
btsure.setForeground(Color.blue);
pchangefalse.add(lchangefalse);
pchangefalse.add(btsure);
pchangefalse.add(lb);
fchangefalse.add(pchangefalse,"Center");
lchangefalse.setBounds(80,25,150,30);
btsure.setBounds(180,60,90,30);
lb.setBounds(0,0,300,140);
btsure.addActionListener(this);
fchangefalse.setLocation(530,400);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -