2023年5月18日12:26:54 修改音乐列表 添加 鼠标滑过样式
parent
cb2663e8c7
commit
5f4734f470
|
|
@ -581,15 +581,19 @@ public class MusicController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String color_cell = "#f4f4f4";
|
||||||
|
|
||||||
private void list_cell() {
|
private void list_cell() {
|
||||||
listView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
|
listView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
|
||||||
|
private int position;
|
||||||
|
Text text = null;
|
||||||
public ListCell<File> call(ListView<File> param) {
|
public ListCell<File> call(ListView<File> param) {
|
||||||
final ListCell<File> cell = new ListCell<File>() {
|
final ListCell<File> cell = new ListCell<File>() {
|
||||||
protected void updateItem(File item, boolean empty) {
|
protected void updateItem(File item, boolean empty) {
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
if (!empty && item != null) {
|
if (!empty && item != null) {
|
||||||
|
text = new Text(sb.substring(0, sb.length() - 4));
|
||||||
sb = new StringBuffer(item.getName());
|
sb = new StringBuffer(item.getName());
|
||||||
Text text = new Text(sb.substring(0, sb.length() - 4));
|
|
||||||
text.setWrappingWidth(300.0D);
|
text.setWrappingWidth(300.0D);
|
||||||
text.setTextAlignment(TextAlignment.CENTER);
|
text.setTextAlignment(TextAlignment.CENTER);
|
||||||
if (this.getIndex() == MusicController.this.playindex.get()) {
|
if (this.getIndex() == MusicController.this.playindex.get()) {
|
||||||
|
|
@ -611,6 +615,19 @@ public class MusicController {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cell.hoverProperty().addListener((observableValue, aBoolean, t1) -> {
|
||||||
|
if (t1 && !text.getText().equals("")) {
|
||||||
|
position = listView.getItems().indexOf(text.getText());
|
||||||
|
text.setFont(new Font(16));
|
||||||
|
listView.getFocusModel().focus(position);
|
||||||
|
cell.setStyle("-fx-background-color: #369e7d");
|
||||||
|
} else {
|
||||||
|
text.setFont(new Font(13));
|
||||||
|
cell.setStyle("-fx-background-color: " + color_cell);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
MenuItem mi1 = new MenuItem("从列表中移除");
|
MenuItem mi1 = new MenuItem("从列表中移除");
|
||||||
mi1.setOnAction(new EventHandler<ActionEvent>() {
|
mi1.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
|
|
@ -698,11 +715,6 @@ public class MusicController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void addDir(File file) {
|
public static void addDir(File file) {
|
||||||
File[] addfiles = file.listFiles((dir, name) -> name.endsWith("mp3"));
|
File[] addfiles = file.listFiles((dir, name) -> name.endsWith("mp3"));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue