📄 bookdelete.java
字号:
package client;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import com.swtdesigner.SwingResourceManager;
import sever.business.iface.ILibrarianInfoIface;
import sever.business.impl.IlibrarianInfoImpl;
import sever.entity.BookInfo;
public class BookDelete extends JFrame{
private JTextField text;
private JTextField text1;
private JFrame frame;
ImageIcon image=new ImageIcon("E:\\image\\1.JPG");
ImageIcon image2=new ImageIcon("E:\\image\\1.JPG");
ImageIcon image3=new ImageIcon("E:\\image\\3.JPG");
ImageIcon image4=new ImageIcon("E:\\image\\two.JPG");
/**
* Launch the application
* @param args
*/
// public static void main(String args[]) {
// try {
// BookDelete window = new BookDelete();
// window.setVisible(true);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* Create the application
*/
public BookDelete() {
new JFrame();
getContentPane().setLayout(null);
setBounds(190, 135,365, 208);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("删除书籍");
final JLabel label = new JLabel();
label.setText("按书名");
label.setFont(new Font("@黑体", Font.PLAIN, 14));
label.setBounds(21, 90, 42, 15);
getContentPane().add(label);
text1 = new JTextField();
text1.setBounds(75, 85, 99, 25);
getContentPane().add(text1);
final JLabel label_1 = new JLabel();
label_1.setFont(new Font("@黑体", Font.PLAIN, 14));
label_1.setText("按编号");
label_1.setBounds(21, 42, 42, 15);
getContentPane().add(label_1);
text = new JTextField();
text.setBounds(75, 37, 99, 25);
getContentPane().add(text);
final JButton button = new JButton();
button.setText("确认");
button.addActionListener(new ActionListener() { //按编号删除书籍
public void actionPerformed(ActionEvent e) {
if(text.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入编号");
}
else{
int i=JOptionPane.showOptionDialog(null, "是否删除", "警告", JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION, null, null, null);
if(i==0){
BookInfo book=new BookInfo();
book.setBookNumber(Integer.parseInt(text.getText().trim()));
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.deletebook(book);
JOptionPane.showMessageDialog(null, "已成功删除!");
}
else{
dispose();
}
}
}
});
button.setFont(new Font("@黑体", Font.PLAIN, 14));
button.setBounds(180, 37, 70, 25);
getContentPane().add(button);
final JButton button_1 = new JButton();
button_1.setText("确认");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { //按书名删除书籍
if(text1.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入书本名");
}
else{
int i=JOptionPane.showOptionDialog(null, "是否删除", "警告", JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION, null, null, null);
if(i==0){
BookInfo book=new BookInfo();
book.setBookName(text1.getText().trim());
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.deletebooktwo(book);
}else{
dispose();
}
}
}
});
button_1.setFont(new Font("@黑体", Font.PLAIN, 14));
button_1.setBounds(180, 85, 70, 25);
getContentPane().add(button_1);
final JLabel label_2 = new JLabel();
label_2.setBorder(new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));//
label_2.setBounds(86, 128, 198, 25);
getContentPane().add(label_2);
getContentPane().setBackground(new Color(224, 235, 237));
final JButton button_2 = new JButton();
button_2.setFont(new Font("@黑体", Font.PLAIN, 14));
button_2.setText("验证");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookInfo book=new BookInfo();
book.setBookNumber(Integer.parseInt(text.getText().trim()));
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.lookbook(book);
if(bl==true){
label_2.setText("该书存在");
}
else{
label_2.setText("该书不存在");
}
}
});
button_2.setBounds(259, 37, 70, 25);
getContentPane().add(button_2);
final JButton button_3 = new JButton();
button_3.setFont(new Font("@黑体", Font.PLAIN, 14));
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookInfo book=new BookInfo();
book.setBookName(text1.getText().trim());
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.lookupbook(book);
if(bl==true){
label_2.setText("该书存在");
}else{
label_2.setText("该书不存在");
}
}
});
button_3.setText("验证");
button_3.setBounds(258, 84, 70, 25);
getContentPane().add(button_3);
setIconImage(SwingResourceManager.getImage(BookDelete.class, "/LOGO.jpg"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -