第四,在jScrollPane1中建一个表格用来显示数据库数据的内容,在组件盘内点选Swing 页签,选取JTable图标,将Jtable加入到jScrollPane1中。
最后,将this中的defaultCloseOperation改为EXIT_ON_CLOSE,这样在关闭窗口时程序会自动退出。
程序源代码如下(除中文注释部分的两句是自己加上去,其余是自动生成):
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Vector; import javax.swing.table.DefaultTableModel; public class Frame1 extends JFrame { BorderLayout borderLayout1 = new BorderLayout(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); JPanel jPanel3 = new JPanel(); JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); FlowLayout flowLayout1 = new FlowLayout(); FlowLayout flowLayout2 = new FlowLayout(); JButton jButton2 = new JButton(); JButton jButton3 = new JButton(); JButton jButton4 = new JButton(); GridLayout gridLayout1 = new GridLayout(); JScrollPane jScrollPane1 = new JScrollPane(); JTable jTable1 = new JTable();
(编辑:aniston)
|