📄 contentmanager.java
字号:
package clientPackage;
import mediaPackage.*;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeSupport;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class ContentManager extends JPanel implements ActionListener,ListSelectionListener{
private JList list=new JList();
private JButton upButton=new JButton("UP");
private JButton downButton=new JButton("DOWN");
private JButton importButton=new JButton("IMPORT");
private JPanel panel=new JPanel();
private PropertyChangeSupport propertySupport;
private int mCategory=-1;
private Vector listData=new Vector();
public ContentManager(){
super();
upButton.addActionListener(this);
downButton.addActionListener(this);
importButton.addActionListener(this);
list.setVisibleRowCount(5);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(this);
propertySupport=new PropertyChangeSupport(this);
panel.setLayout(new GridLayout(1,3));
panel.add(upButton);
panel.add(downButton);
panel.add(importButton);
setLayout(new BorderLayout());
add(new JScrollPane(list),BorderLayout.CENTER);
add(panel,BorderLayout.SOUTH);
}
public void addPropertyChangeListener(ClientUI clientUI) {
propertySupport.addPropertyChangeListener(clientUI);
}
public void enableContentManager(boolean b, int myCategory) {
mCategory=myCategory;
if (mCategory==Constants.USER) this.importButton.setEnabled(false);
}
public void addURL(String strURL) {
listData.add(strURL);
list.setListData(listData);
}
public void actionPerformed(ActionEvent e) {
Object o=e.getSource();
if (o==importButton){
propertySupport.firePropertyChange("importFired",null,null);
}
}
public void valueChanged(ListSelectionEvent e) {
// TODO Auto-generated method stub
int i=list.getSelectedIndex();
if (i<listData.size()&&i>=0)
propertySupport.firePropertyChange("selectionChanged",null,listData.get(i));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -