tuich.java

来自「小程序 自己写的 请多多指教 希望高手不吝赐教」· Java 代码 · 共 44 行

JAVA
44
字号
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
 class tuich extends JFrame implements ActionListener
{   private condb con=null;
    private ResultSet rs=null;
    private String sql=null;
    private JLabel q1=new JLabel("是否确定退出本软件?");  
    private JButton d1=new JButton("确认");
    private JButton d2=new JButton("返回");
    
   public tuich()
  { super("结束");
    setSize(300,180);
    setBackground(Color.LIGHT_GRAY);
    this.setLocationRelativeTo(this.getParent());
    setResizable(false);
    Container cont=this.getContentPane();
    cont.setLayout(null);
    
    q1.setBounds(80,20,200,30);
    d1.setBounds(50,80,80,30);
    d2.setBounds(150,80,80,30);
    
    cont.add(q1);
    cont.add(d1);
    cont.add(d2);
    d1.addActionListener(this);
    d2.addActionListener(this);

    setVisible(true);

   }
 

public void actionPerformed(ActionEvent te)
 {   
    if(te.getActionCommand().equals("确认"))
     { dispose();System.exit(0);}
    if(te.getActionCommand().equals("返回"))
      dispose();  
 } 
}   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?