JAVA怎么样可以自动填写表单,点击
1个回答
展开全部
/*
* checkresult.java
*
* Created on __DATE__, __TIME__
*/
package design;
import javax.swing.JOptionPane;
import dealingdata.Account;
import dealingdata.AccountDAO;
/**
*
* @author __USER__
*/
public class checkresult extends javax.swing.JFrame {
/** Creates new form checkresult */
public checkresult() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jTable1.setModel(new javax.swing.table.DefaultTableModel(
a, name));
jScrollPane1.setViewportView(jTable1);
jLabel1.setFont(new java.awt.Font("微软雅黑", 3, 36));
jLabel1.setForeground(new java.awt.Color(0, 0, 204));
jLabel1.setText("\u673a\u7968\u9884\u8ba2\u8868");
jButton1.setFont(new java.awt.Font("微软雅黑", 3, 24));
jButton1.setForeground(new java.awt.Color(0, 0, 204));
jButton1.setText("\u786e\u5b9a");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cofirm(evt);
}
});
jButton2.setForeground(new java.awt.Color(0, 0, 255));
jButton2.setText("\u663e\u793a\u6570\u636e");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showrecord(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.add(
148,
148,
148)
.add(
jLabel1)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
jButton2))
.add(
layout
.createSequentialGroup()
.add(
57,
57,
57)
.add(
jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
466,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(
layout
.createSequentialGroup()
.add(
236,
236,
236)
.add(
jButton1)))
.addContainerGap(120, Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING,
false)
.add(
layout
.createSequentialGroup()
.addContainerGap()
.add(
jLabel1)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED))
.add(
org.jdesktop.layout.GroupLayout.TRAILING,
layout
.createSequentialGroup()
.addContainerGap(
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(
jButton2)
.add(
17,
17,
17)))
.add(
jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
299,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED,
21, Short.MAX_VALUE).add(
jButton1).add(27, 27, 27)));
pack();
}// </editor-fold>
//GEN-END:initComponents
private void showrecord(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Account account=new Account();
AccountDAO show=new AccountDAO();
boolean result=show.loadInformation(account);
if(result==true){
jTable1.setModel(new javax.swing.table.DefaultTableModel(
show.a, name));
JOptionPane.showMessageDialog(null,"恭喜您,操作成功!", "成功", JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null, "对不起,无法显示结果", "提示", JOptionPane.ERROR_MESSAGE);
}
}
private void cofirm(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
design.bookticket.main(null);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new checkresult().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private Object[][] a=new Object[][]{{},{},{}};
// End of variables declaration//GEN-END:variables
public static Object name[]=new String[] { "姓名",
"性别", "工作单位", "号码","时间","目的地" };
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询