contentmanager.java

来自「一个实现网络会议的软件.包含三个包.其中一个包需JMF的支持.」· Java 代码 · 共 67 行

JAVA
67
字号
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 + =
减小字号Ctrl + -
显示快捷键?