📄 tjtable.java
字号:
/* *TJtable.java主要功能是建立右侧界面中的表格界面。 *该界面只显示信息。 */ import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.*;import javax.swing.*;import javax.swing.BorderFactory; import javax.swing.border.Border;import javax.swing.border.TitledBorder;import javax.swing.border.EtchedBorder;
import java.awt.event.*;
import javax.swing.event.*;public class TJtable extends JPanel implements ActionListener { JTable table; Border b = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); String[][] data = new String[15][7]; public TJtable() { String[] columnNames = {"资产名称", "样式", "价格", "购入日期", "状态", "借用人", "是否归还"}; setLayout(new BorderLayout()); table = new JTable(data, columnNames); JScrollPane sp = new JScrollPane(table); add(sp,BorderLayout.CENTER); JButton fetch=new JButton("查询资产"); fetch.setActionCommand("fetch");
fetch.addActionListener(this); JButton prev=new JButton("上一页"); prev.setActionCommand("prev"); prev.setEnabled(false);
prev.addActionListener(this); JButton next=new JButton("下一页"); next.setActionCommand("next"); next.setEnabled(false);
next.addActionListener(this);
JPanel p=new JPanel(); p.add(prev);
p.add(fetch); p.add(next);
add(p,BorderLayout.SOUTH); setBorder(b); setVisible(true); } public void actionPerformed(ActionEvent e) { for (int i=0;i<15;i++) for (int j=0;j<7;j++) table.setValueAt("",i,j); int k = (new TJtableModel()).selAssets(data); for (int i=0;i<k;i++) for (int j=0;j<7;j++) table.setValueAt(data[i][j],i,j); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -