📄 xgdialog.java~60~
字号:
package myproject;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.sql.Connection;
import java.awt.event.*;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class XgDialog extends JDialog {
private JPanel panel1 = new JPanel();
private JLabel jLabel1 = new JLabel();
private JTextField indexField = new JTextField();
private JButton selectButt = new JButton();
private JButton jButton2 = new JButton();
private JButton jButton3 = new JButton();
private Border border1;
Connection con = null;
Frame2 frame = null;
String str = null;
private JLabel jLabel2 = new JLabel();
private JTextField tiaoField = new JTextField();
private JLabel jLabel3 = new JLabel();
private Border border2;
private GridBagLayout gridBagLayout1 = new GridBagLayout();
private JScrollPane jScrollPane1 = new JScrollPane();
private JTextArea text = new JTextArea(2,5);
private Border border3;
public XgDialog(Frame2 frame, String title, boolean modal) {
super(frame, title, modal);
try {
this.frame = frame;
this.con = frame.con1;
text.setLineWrap(true);
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public XgDialog() {
this(null, "删除对话框", false);
}
private void jbInit() throws Exception {
border1 = BorderFactory.createEmptyBorder(0,10,15,10);
border2 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(124, 124, 124),new Color(178, 178, 178));
border3 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(124, 124, 124),new Color(178, 178, 178));
panel1.setLayout(gridBagLayout1);
jLabel1.setText("请输入删除的文件名:");
selectButt.setText("查找");
selectButt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
selectButt_actionPerformed(e);
}
});
jButton2.setText("删除");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
jButton3.setText("取消");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton3_actionPerformed(e);
}
});
jLabel2.setText("第");
jLabel3.setText("条");
panel1.setBorder(border1);
text.setBorder(border3);
text.setText("");
panel1.add(selectButt, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 0, 0, 0), 0, 0));
panel1.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(16, -1, 0, 0), 3, 12));
panel1.add(jLabel2, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(16, 0, 0, 0), 8, 12));
panel1.add(tiaoField, new GridBagConstraints(4, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(16, 0, 0, 0), 32, 9));
panel1.add(jLabel3, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(16, 6, 0, 0), 13, 12));
panel1.add(indexField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0
,GridBagConstraints.SOUTHEAST, GridBagConstraints.HORIZONTAL, new Insets(16, 8, 0, 0), 102, 9));
panel1.add(jButton2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 3, 0));
panel1.add(jButton3, new GridBagConstraints(2, 2, 3, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 13, 1, 31), 3, 0));
panel1.add(jScrollPane1, new GridBagConstraints(0, 1, 7, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(14, 0, 11, 8), 275, 140));
jScrollPane1.getViewport().add(text, null);
this.getContentPane().add(panel1, BorderLayout.SOUTH);
}
void selectButt_actionPerformed(ActionEvent e) {
try{
String indexStr = indexField.getText();
String tiao = tiaoField.getText();
Statement sta = con.createStatement();
String sql = "select tiaowen from fltw where sy_id='"+indexStr+"' and tk_id="+tiao;
ResultSet set = sta.executeQuery(sql);
text.setText("");
while(set.next()){
String temp = set.getString(1);
text.append(temp.trim()+"\n");
// text.setText(temp.trim());
}
set.close();
sta.close();
frame.validate();
frame.repaint();
}
catch(SQLException ex){
ex.printStackTrace();
}
}
void jButton3_actionPerformed(ActionEvent e) {
this.setVisible(false);
this.dispose();
}
void jButton2_actionPerformed(ActionEvent e) {
try{
String indexStr = indexField.getText();
String tiao = tiaoField.getText();
Statement sta = con.createStatement();
String sql = "delete from fltw where sy_id='"+indexStr+"' and tk_id="+tiao;
int i = sta.executeUpdate(sql);
if(i > 0 ){
text.setText("");
JOptionPane.showMessageDialog(this, "删除成功!!!");
}
}
catch(SQLException ex){
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -