📄 applicationframe.java
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov Date: 2007-5-16 21:07:27
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: ApplicationFrame.java
import com.sun.rowset.CachedRowSetImpl;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.sql.*;
import java.util.Properties;
import javax.sql.rowset.CachedRowSet;
import javax.swing.*;
public class ApplicationFrame extends JFrame
{
public ApplicationFrame()
{
jPanel1 = new JPanel();
jPanel2 = new JPanel();
jButtonWajue = new JButton();
jButtonDaochu = new JButton();
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jTextField1 = new JTextField(5);
jTextField2 = new JTextField(5);
jButton2 = new JButton();
borderLayout1 = new BorderLayout();
borderLayout2 = new BorderLayout();
contentPane = (JPanel)getContentPane();
contentPane.setLayout(borderLayout2);
setSize(new Dimension(600, 400));
setTitle("\u6570\u636E\u6316\u6398");
jButtonWajue.setText("\u6316\u6398");
jButtonWajue.addActionListener(new ApplicationFrame_jButton1_actionAdapter(this));
jButtonDaochu.setText("\u6570\u636E\u5BFC\u51FA");
jButtonDaochu.addActionListener(new ApplicationFrame_jButton4_actionAdapter(this));
jLabel1.setText("\u652F\u6301\u5EA6");
jLabel2.setText("\u7F6E\u4FE1\u5EA6");
jTextField1.addActionListener(new ApplicationFrame_jTextField1_actionAdapter(this));
jTextField2.addActionListener(new ApplicationFrame_jTextField2_actionAdapter(this));
tableNames = new JComboBox();
tableNames.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionevent)
{
try
{
if(scrollPane != null)
remove(scrollPane);
String s = (String)tableNames.getSelectedItem();
if(rs != null)
rs.close();
String s1 = (new StringBuilder()).append("SELECT * FROM ").append(s).toString();
rs = stat.executeQuery(s1);
if(scrolling)
{
model = new ResultSetTableModel(rs);
for(int i = 0; i < model.getColumnCount(); i++)
Apriori.TableHeader[i] = model.getColumnName(i);
} else
{
CachedRowSetImpl cachedrowsetimpl = new CachedRowSetImpl();
cachedrowsetimpl.populate(rs);
model = new ResultSetTableModel(cachedrowsetimpl);
for(int j = 0; j < model.getColumnCount(); j++)
Apriori.TableHeader[j] = model.getColumnName(j);
}
JTable jtable = new JTable(model);
scrollPane = new JScrollPane(jtable);
add(scrollPane, "Center");
validate();
}
catch(SQLException sqlexception1)
{
sqlexception1.printStackTrace();
}
}
final ApplicationFrame this$0;
{
this$0 = ApplicationFrame.this;
super();
}
});
jPanel1.add(tableNames);
jPanel1.add(jLabel1);
jPanel1.add(jTextField1);
jPanel1.add(jLabel2);
jPanel1.add(jTextField2);
jPanel2.add(jButtonDaochu);
jPanel2.add(jButtonWajue);
contentPane.add(jPanel1, "North");
contentPane.add(jPanel2, "South");
try
{
conn = getConnection();
DatabaseMetaData databasemetadata = conn.getMetaData();
if(databasemetadata.supportsResultSetType(1004))
{
scrolling = true;
stat = conn.createStatement(1004, 1007);
} else
{
stat = conn.createStatement();
scrolling = false;
}
ResultSet resultset;
for(resultset = databasemetadata.getTables(null, null, null, new String[] {
"TABLE"
}); resultset.next(); tableNames.addItem(resultset.getString(3)));
resultset.close();
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
catch(ClassNotFoundException classnotfoundexception)
{
classnotfoundexception.printStackTrace();
}
}
public void jButtonWajue_actionPerformed(ActionEvent actionevent)
{
try
{
c = jTextField1.getText();
d = jTextField2.getText();
a = Double.parseDouble(c);
b = Double.valueOf(d).doubleValue();
try
{
if(a <= 1.0D && a > 0.0D && b <= 1.0D && b > 0.0D)
p = true;
else
JOptionPane.showMessageDialog(null, "\u8BF7\u8F93\u5165\u6570\u5B57\u4ECB\u4E8E0~1!");
}
catch(NumberFormatException numberformatexception)
{
numberformatexception.printStackTrace();
}
if(p)
{
Apriori apriori = new Apriori();
apriori.main(a, b);
ResultFrame resultframe = new ResultFrame();
resultframe.main();
Dimension dimension = resultframe.getPreferredSize();
Dimension dimension1 = getSize();
Point point = getLocation();
resultframe.setLocation((dimension1.width - dimension.width) / 2 + point.x, (dimension1.height - dimension.height) / 2 + point.y);
resultframe.pack();
resultframe.show();
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
public void jButtonDaochu_actionPerformed(ActionEvent actionevent)
{
try
{
Connection connection = getConnection();
Statement statement = connection.createStatement();
String s = (String)tableNames.getSelectedItem();
String s1 = (new StringBuilder()).append("SELECT * FROM ").append(s).toString();
ResultSet resultset = statement.executeQuery(s1);
try
{
ResultSetMetaData resultsetmetadata = resultset.getMetaData();
int i = resultsetmetadata.getColumnCount();
StringBuffer stringbuffer = new StringBuffer(500);
for(; resultset.next(); stringbuffer.append("\r\n"))
{
for(int j = 1; j <= i; j++)
if(j != i)
stringbuffer.append((new StringBuilder()).append(resultset.getString(j)).append(",").toString());
else
stringbuffer.append(resultset.getString(i));
}
FileWriter filewriter = new FileWriter("c:/shujuku.txt");
filewriter.write(stringbuffer.toString());
filewriter.write("%");
filewriter.close();
}
catch(IOException ioexception1)
{
ioexception1.printStackTrace();
}
catch(SQLException sqlexception1)
{
for(; sqlexception1 != null; sqlexception1 = sqlexception1.getNextException())
sqlexception1.printStackTrace();
}
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
}
catch(ClassNotFoundException classnotfoundexception)
{
classnotfoundexception.printStackTrace();
}
catch(SQLException sqlexception)
{
for(; sqlexception != null; sqlexception = sqlexception.getNextException())
sqlexception.printStackTrace();
}
}
public void jTextField1_actionPerformed(ActionEvent actionevent)
{
}
public void jTextField2_actionPerformed(ActionEvent actionevent)
{
}
public static Connection getConnection()
throws SQLException, IOException, ClassNotFoundException
{
Properties properties = new Properties();
FileInputStream fileinputstream = new FileInputStream("database.properties");
properties.load(fileinputstream);
fileinputstream.close();
String s = properties.getProperty("jdbc.drivers");
if(s != null)
System.setProperty("jdbc.drivers", s);
String s1 = properties.getProperty("jdbc.url");
String s2 = properties.getProperty("jdbc.username");
String s3 = properties.getProperty("jdbc.password");
return DriverManager.getConnection(s1, s2, s3);
}
private JScrollPane scrollPane;
private ResultSetTableModel model;
private JComboBox tableNames;
private ResultSet rs;
private Connection conn;
private Statement stat;
private boolean scrolling;
JPanel contentPane;
JPanel jPanel1;
JPanel jPanel2;
JButton jButtonWajue;
JButton jButtonDaochu;
JLabel jLabel1;
JLabel jLabel2;
boolean p;
double a;
double b;
String c;
String d;
JTextField jTextField1;
JTextField jTextField2;
JButton jButton2;
BorderLayout borderLayout1;
BorderLayout borderLayout2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -