?? stafflistwindow.java
字號(hào):
package crms.applet.company;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import crms.ui.*;import crms.applet.*;import crms.vo.*;public class StaffListWindow extends CRMSWindow { DefaultListModel staffModel = new DefaultListModel(); JList staffList = new JList(staffModel); JScrollPane staffScroll = new JScrollPane(staffList); public void display() { init(); setVisible(true); } public void init() { // window display attributes setTitle("Staff List"); setSize(350,500); center(); Container pane = getContentPane(); pane.setBackground(Color.WHITE); pane.setLayout(new BorderLayout()); // The staff list staffScroll.setBackground(Color.WHITE); staffScroll.setBorder(new EmptyBorder(5,5,5,5)); pane.add(staffScroll, BorderLayout.CENTER); staffList.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent ev) { if (ev.getClickCount() == 2) { processStaffMemberView(); } } } ); // lower buttons - creation JButton viewBtn = new JButton("View"); viewBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { processStaffMemberView(); } } ); JButton closeBtn = new JButton("Close"); closeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeWindow(); } } ); // lower buttons - assembly CRMSButtonBar buttons = new CRMSButtonBar(); buttons.addButton(CRMSButtonBar.RIGHT, viewBtn); buttons.addButton(CRMSButtonBar.RIGHT, closeBtn); pane.add(buttons, BorderLayout.SOUTH); } public void setStaff(java.util.List staff) { Iterator i = staff.iterator(); staffModel.removeAllElements(); while (i.hasNext()) { StaffMember sm = (StaffMember) i.next(); staffModel.addElement(sm); } } public void processStaffMemberView() { int index = staffList.getSelectedIndex(); if (index >= 0) { StaffMemberWindow smw = new StaffMemberWindow(); StaffMember sm = (StaffMember)staffModel.getElementAt(index); System.out.println("staff member is " + sm); smw.setStaffMember(sm); smw.display(); } }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -