📄 tabledatasetframe.java~22~
字号:
package dataexpress;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.dx.dataset.*;import com.borland.dbswing.*;public class TableDataSetFrame extends JFrame implements ActionListener { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); TextDataFile textDataFile1 = new TextDataFile(); TableDataSet tableDataSet1 = new TableDataSet(); TableScrollPane tableScrollPane1 = new TableScrollPane(); JdbTable jdbTable1 = new JdbTable(); JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JButton jButton3 = new JButton(); JButton jButton4 = new JButton(); public TableDataSetFrame() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("TableDataSet示例"); //与bookcategory.txt文本文件建立连接,默认路径是程序的运行路径 textDataFile1.setFileName("bookcategory.txt"); //与文本文件的数据源建立连系 tableDataSet1.setDataFile(textDataFile1); //设置表格的数据源 jdbTable1.setDataSet(tableDataSet1); jButton1.setText("第一条"); jButton2.setText("上一条"); jButton3.setText("下一条"); jButton4.setText("最后一条"); jButton1.setActionCommand("first"); jButton2.setActionCommand("prior"); jButton3.setActionCommand("next"); jButton4.setActionCommand("last"); jButton1.addActionListener(this); jButton2.addActionListener(this); jButton3.addActionListener(this); jButton4.addActionListener(this); jPanel1.add(jButton1, null); jPanel1.add(jButton2, null); jPanel1.add(jButton3, null); jPanel1.add(jButton4, null); tableScrollPane1.getViewport().add(jdbTable1, null); contentPane.add(tableScrollPane1, BorderLayout.CENTER); contentPane.add(jPanel1, BorderLayout.SOUTH); } protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public void actionPerformed(ActionEvent e) { String actionComm = e.getActionCommand(); if (actionComm.equals("first")) { //将指针移到数据集的第一条 tableDataSet1.first(); } if (actionComm.equals("prior")) { //将指针上移一条 tableDataSet1.prior(); } if (actionComm.equals("next")) { //将指针下移一条 tableDataSet1.next(); } if (actionComm.equals("last")) { //将指针移到数据集的最后一条 tableDataSet1.last(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -