📄 staffmemberwindow.java
字号:
package crms.applet;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.awt.event.*;import crms.ui.*;import crms.vo.StaffMember;public class StaffMemberWindow extends CRMSWindow { CallbackDestination destination; StaffMember staffMember = null; // display fields JTextField textName = new JTextField(); JTextField textUID = new JTextField(); JTextField textUIDNumber = new JTextField(); JTextField textDepartment = new JTextField(); JTextField textLocation = new JTextField(); JTextField textTitle = new JTextField(); JTextField textMobile = new JTextField(); JTextField textEmail = new JTextField(); public StaffMemberWindow() { // initialise the display setSize(500,300); center(); setTitle("View Staff"); } public void init() { Container pane = getContentPane(); setBackgroundFields(new Color(0xF0, 0xFF, 0xF0)); setEditable(false); pane.setLayout(new BorderLayout()); pane.setBackground(Color.WHITE); // create the grid display Insets defaultInsets = new Insets(4,0,0,4); JPanel grid = new JPanel(new GridBagLayout()); grid.setBackground(Color.WHITE); grid.setBorder(new EmptyBorder(5,5,5,5)); grid.add(new JLabel("Name"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textName, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("User ID"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textUID, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("Division"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textDepartment, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("Location"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textLocation, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("Job Title"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textTitle, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("Email"), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textEmail, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); grid.add(new JLabel("Mobile"), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); grid.add(textMobile, new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); // create some buttons JButton btnClose = new JButton("Close"); btnClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeWindow(); } } ); // package and add to display CRMSButtonBar buttons = new CRMSButtonBar(); buttons.addButton(CRMSButtonBar.RIGHT, btnClose); // finalise the display pane.add(grid, BorderLayout.CENTER); pane.add(buttons, BorderLayout.SOUTH); } // functional stuff public void setStaffMember(StaffMember member) { staffMember = member; if (member == null) { System.out.println("StaffMemberWindow::setStaffMember - staff member is null"); return; } String strName = (staffMember.getFirstName() + " " + staffMember.getLastName()).trim(); // load the field data textName.setText(strName); textUID.setText(staffMember.getUID()); textDepartment.setText(staffMember.getDepartment()); textLocation.setText(staffMember.getLocation()); textTitle.setText(staffMember.getJobTitle()); textMobile.setText(staffMember.getMobile()); textEmail.setText(staffMember.getEmail()); // update window title setTitle("View Staff - " + strName); } // display stuff public void display() { init(); this.setVisible(true); } public void setBackgroundFields(Color color) { textName.setBackground(color); textUID.setBackground(color); textUIDNumber.setBackground(color); textDepartment.setBackground(color); textLocation.setBackground(color); textTitle.setBackground(color); textMobile.setBackground(color); textEmail.setBackground(color); } public void setEditable(boolean editable) { textName.setEditable(editable); textUID.setEditable(editable); textUIDNumber.setEditable(editable); textDepartment.setEditable(editable); textLocation.setEditable(editable); textTitle.setEditable(editable); textMobile.setEditable(editable); textEmail.setEditable(editable); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -