📄 cardlistpanel.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package cardmanager;import java.awt.BorderLayout;import javax.swing.BorderFactory;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.ListSelectionModel;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;/** * * @author zhaolin */public class CardListPanel extends JPanel{ private JList list; private DefaultListModel model; public CardListPanel(){ initConponent(); } private void initConponent() { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createTitledBorder("名片列表")); list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setModel(CardManagerModel.getInstance().getListModel()); list.addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e) { Card selectedCard = (Card)list.getSelectedValue(); CardManagerModel.getInstance().setCurrentCard(selectedCard); CardManagerFrame cmf = (CardManagerFrame)getTopLevelAncestor(); cmf.fireCardChanged(); } }); this.add(new JScrollPane(list)); } public static void main(String[] args) { JFrame f = new JFrame(); f.setContentPane(new CardListPanel()); f.pack(); f.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -