📄 教室情况.java
字号:
/*
* 教室情况.java
*
* Created on 2008年11月15日, 下午2:30
*/
package javaapplication1;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
/**
*
* @author mis06
*/
public class 教室情况 extends javax.swing.JPanel {
/** Creates new form 教室情况 */
public 教室情况() {
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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1.setText("\u67e5\u770b\u672a\u5360\u7528\u6559\u5ba4\u60c5\u51b5");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.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()
.addContainerGap()
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 428, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(130, 130, 130)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 160, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(57, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jButton1)
.add(16, 16, 16)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 282, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(37, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Statement statement;
try{
Connect con=new Connect();
statement=con.con.createStatement();
StringBuffer results=new StringBuffer();
String s="SELECT * FROM 教室 WHERE 状态='未占用'";
ResultSet resultSet=statement.executeQuery(s);
ResultSetMetaData metaData=resultSet.getMetaData();
int numberOfColumns=metaData.getColumnCount();
for(int i=1;i<=numberOfColumns;i++)
results.append(metaData.getColumnName(i)+"\t");
results.append("\n");
while(resultSet.next())
{
for(int i=1;i<=numberOfColumns;i++)
results.append(resultSet.getObject(i)+"\t");
results.append("\n");
}
jTextArea1.setText(results.toString());
jTextArea1.setEditable(false);
}
catch(SQLException sqlException){
JOptionPane.showMessageDialog(null,sqlException.getMessage(),"Database Error",JOptionPane.ERROR_MESSAGE);
System.exit(1);}
catch(ClassNotFoundException classNotFound){
JOptionPane.showMessageDialog(null,classNotFound.getMessage(),"Driver Not Found",JOptionPane.ERROR_MESSAGE);
System.exit(1); }// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -