⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windowconfirm.java

📁 图书管理系统。 借书
💻 JAVA
字号:
package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class WindowConfirm extends JFrame implements ActionListener
{
	  public WindowConfirm()
	  {
	   setSize(300,150);
	   Dimension screen = getToolkit().getScreenSize();  //得到屏幕尺寸
	    setLocation((screen.width-getSize().width)/2,(screen.height-getSize().height)/2); //设置窗口位置
	   JLabel confirm=new JLabel("                                    您确认退出吗?");
	   confirm.setBackground(Color.LIGHT_GRAY);
	   JButton y=new JButton("确定");
	   y.addActionListener(this);
	   JButton n=new JButton("取消");
	   n.addActionListener(this);
	   Container con=getContentPane();
	   con.setLayout(new BorderLayout());
	   JPanel b=new JPanel();
	   b.add(y);
	   b.add(n);
	   con.add(b,BorderLayout.SOUTH);
	   con.add(confirm,BorderLayout.CENTER);
	   setVisible(true);
	  }
	  public void actionPerformed(ActionEvent e)
	  {
	   if(e.getActionCommand().equals("确定"))
	    System.exit(0);
	   else if(e.getActionCommand().equals("取消"))
	    dispose();
	  }
	 }

⌨️ 快捷键说明

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