-1
我一直在試圖創建一個音樂播放器,並且需要聽一個時間滑塊。所以我加入的時間幻燈片,這是我得到的錯誤:我的方法不抽象,不能覆蓋另一種方法
我一直在試圖讓我的頭圍繞如何解決這個錯誤,並覆蓋全業務。
任何人都可以指出我正確的方向如何解決這個錯誤?
我的代碼:
public class graphicalController implements Initializable
{
//GUI Decleration
@FXML
public Button centreButton;
@FXML
public Button backButton;
@FXML
public Button forwardButton;
@FXML
public ToggleButton muteToggle;
@FXML
public MenuItem loadFolder;
@FXML
public Text nameText;
@FXML
public Text albumText;
@FXML
public Text timeText;
@FXML
public Text artistText;
@FXML
public Slider timeSlider;
@FXML
public Slider volumeSlider;
//Controller Decleration
String absolutePath;
SongQueue q = new SongQueue();
MediaPlayer player;
Status status;
boolean isPlaying = false;
boolean isMuted = false;
boolean isPaused = false;
private Duration duration;
/**
* The constructor. The constructor is called before the initialize()
* method.
*
* Anything in regards to CSS styling with FXML MUST be done within the initialize method.
*/
public graphicalController() {
}
/**
* Initializes the controller class. This method is automatically called
* after the fxml file has been loaded.
*/
@FXML
public void initialize(URL location, ResourceBundle resources)
{
centreButton.setStyle("-fx-background-image: url('/Resources/Play_Button.png')");
centreButton.setText("");
backButton.setStyle("-fx-background-image: url('/Resources/Back_Button.png')");
backButton.setText("");
forwardButton.setStyle("-fx-background-image: url('/Resources/Forward_Button.png')");
forwardButton.setText("");
muteToggle.setStyle("-fx-background-image: url('/Resources/ToggleSound_Button.png')");
muteToggle.setText("");
nameText.setText("");
albumText.setText("");
artistText.setText("");
volumeSlider.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable,
Number oldValue, Number newValue) {
double sliderValue = newValue.intValue();
handleVolumeSlider(sliderValue);
}
});
timeSlider.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable,
Number oldValue, Number newValue) {
//outputTextArea.appendText("Slider Value Changed (newValue: " + newValue.intValue() + ")\n");
}
});
timeSlider.valueProperty().addListener(new InvalidationListener() {
public void invalidated(Observable ov) {
if (timeSlider.isValueChanging()) {
// multiply duration by percentage calculated by slider position
if(duration!=null) {
player.seek(duration.multiply(timeSlider.getValue()/100.0));
}
updateValues();
}
}
});
}
public void setSongText() {
String file = q.peek().fileName;
String songName = q.peek().songName;
String albumName = q.peek().albumName;
String artistName = q.peek().artistName;
if (songName == "") {
songName = "Song name not specified in metadata.";
}
else if (albumName == "")
{
albumName = " Album name not specified in metadata.";
}
else if (artistName == "")
{
artistName = "Artist name not specified in metadata.";
}
nameText.setText(songName);
albumText.setText(albumName);
artistText.setText(artistName);
}
}
你會發現我在初始化方法的問題。
我強烈懷疑你不需要319行代碼來證明你的問題。請減少到[mcve]。 –
公平點。我是在不懶惰的情況下完成的,我只是認爲理解整個項目會是一個更好的選擇。但是,你是對的,我可以刪除一些不屬於這個問題的方法。待命,我現在就做。 –