1
我已經提供了一些部分編寫的類,它們一起編輯mp3 id3v1
文件的信息標記。所有信息都通過GUI顯示。Custom EventListener類
我在這裏感興趣的是DisplayTagPanel
。我如何使用
public void addTagPanelEventListener(TagPanelEventListener tagPanelEvent) {
}
要從編輯按鈕觸發事件? 這裏是使用addTagPanelEventListener
的類以及它實現的接口TagPanelEventListener
。
/**
* This Panel will display the ID3 tag information for read only
* This class should:
* - Configure the textfields for read only
* - Configure the action buttons (Edit)
* - Handle actions on Edit button
* - Fire notifications to listeners on edit button
*/
@SuppressWarnings("serial")
public class DisplayTagPanel extends AbstractTagPanel {
public DisplayTagPanel(ID3v1 id3v1Tag) {
super(id3v1Tag);
validate();
}
@Override
protected void configureActionFields() {
JButton edit = new JButton("Edit");
JPanel editOptionsPanel = new JPanel(new FlowLayout());
editOptionsPanel.add(edit);
this.add(editOptionsPanel, BorderLayout.PAGE_END);
}
public void addTagPanelEventListener(TagPanelEventListener tagPanelEvent) {
}
@Override
protected void configureFields() {
// TODO Auto-generated method stub
}
}
package edu.pitt.cs401.assignment4;
import org.farng.mp3.id3.ID3v1;
/**
* Define events that are triggered by action on Tag Panels
*
*/
public interface TagPanelEventListener {
/**
* The edit action
* @param id3v1 The ID3v1 tag that was loaded from the file is passed as argument
*/
public void onEdit(ID3v1 id3v1);
/**
* Called when the save button is pressed
* @param id3v1Edit This is the edited ID3v1 tag.
*/
public void onSave(ID3v1 id3v1Edit);
/**
* Called when the cancel button is pressed
*/
public void onCancel();
}