📄 companytablecomponent.java
字号:
package crms.applet.company;import crms.ui.*;import crms.vo.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.awt.event.*;public class CompanyTableComponent extends CRMSComponent { public static final int COMPANY_SELECTED = 1; CallbackDestination parent; StaffMember user = null; CompanyDataTableModel resultsModel = new CompanyDataTableModel(); JTable resultsTable = new JTable(resultsModel); JScrollPane resultsScrollPane = new JScrollPane(resultsTable); ArrayList companyList = null; String title = null; public CompanyTableComponent() { this(null, null); } public CompanyTableComponent(CallbackDestination parent) { this(parent, null); } public CompanyTableComponent(CallbackDestination parent, String title) { this.parent = parent; setTitle(title); } /** Set the company to have a list of companies. */ public void setCompanyList(ArrayList companies) { companyList = companies; resultsModel.clear(); for (int i=0; i < companyList.size(); i++) { Company company = (Company)companyList.get(i); resultsModel.addCompany(company); } resultsModel.fireTableDataChanged(); SwingUtilities.updateComponentTreeUI(resultsTable); } public void setUser(StaffMember user) { this.user = user; } public StaffMember getUser() { return user; } public Company getSelected() { Company company = null; if (resultsTable.getSelectedRow() >= 0) { company = (Company)resultsModel.get(resultsTable.getSelectedRow()); } return company; } public void clear() { resultsModel.clear(); companyList = null; } public void init() { // get a copy of this class so that it is accessable within the inner class final CompanyTableComponent component = this; resultsTable.addMouseListener( new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent ev) { if (ev.getClickCount() == 2) { if (parent != null) parent.callback(component, COMPANY_SELECTED, getSelected()); } } } ); setBackground(Color.WHITE); setLayout(new BorderLayout()); add(resultsScrollPane, BorderLayout.CENTER); } public void setTitle(String title) { if (title == null) { this.title = ""; } TitledBorder border = new TitledBorder( new EtchedBorder(EtchedBorder.LOWERED), title); resultsScrollPane.setBorder(border); } public void setBackground(Color color) { if (resultsTable == null) return; resultsTable.setBackground(color); resultsScrollPane.setBackground(color); resultsScrollPane.getViewport().setBackground(color); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -