현재 앱을 개발 중입니다.페이드 전환과 관련된 JavaFX 문제
- 하나의 단계 : 그것은 시각적 구조는 다음과 같다입니다. ApplicationContainer의 ( 는 기본적으로 상단에 도구 모음을 그것의 내부 BorderPane와 StackPane 내 자신의 클래스, 그리고이 센터의에서 현재 페이지)가
- 하나의 장면.
- 여러 ApplicationLayout의
ApplicationLayout는 머리글과 바닥 글 (바닥 글이 아직 구현되지 않음)이 있고 다음과 같습니다
내가 fadeIn을 구현하기 위해 관리했습니다/fadeOut는 StackPane을 BorderPane의 중심으로 설정하고, 페이지를 추가하고, 그 위에 흰색 VBox를 추가하여 페이지 사이를 전환합니다. 따라서 페이지를 전환하기 전에이 흰색 VBox의 FadeTransitions을 사용합니다.
setOpacity()
이 어떤 이유로 텍스트 필드 또는 버튼 불투명도를 변경하지 않기 때문에 이런 식으로해야했습니다.
이제 헤더와 똑같은 작업을하려고합니다. 그래서 저는 StackPane을 맨 위에 놓았고, 머리글과 그것에 머리말을 붙였습니다. 이전과 같이 (제목, 화살표 또는 설명의 불투명도 속성을 수정할 수 없습니다. CSS overriding 때문에).
하지만 이번에는 작동하지 않습니다. 헤더 코 베러의 불투명도를 0으로 설정하면 헤더의 내용이 표시되지 않습니다.
내가 원하는 것은 오렌지색 HBox가 아니라 헤더의 구성 요소를 페이드 아웃/페이드 인하는 것입니다.
편집 : 나를
public class Main extends Application {
private Boolean buttonPressed = false;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
BorderPane appWindow = new BorderPane();
appWindow.setStyle("-fx-alignment: center; -fx-padding: 30 0 0 30");
appWindow.setBackground(new Background(new BackgroundFill(Color.PERU, null, null)));
GridPane loginContainer = new GridPane();
appWindow.setCenter(loginContainer);
TextField username = new TextField();
PasswordField password = new PasswordField();
Label userNameDesc = new Label("Username");
Label passwordDesc = new Label("Password");
Button logInBtn = new Button("Log In");
logInBtn.setTranslateX(100);
logInBtn.setTranslateY(20);
logInBtn.setOnAction(event -> {
if (!buttonPressed) {
appWindow.getCenter().setOpacity(30);
buttonPressed = true;
System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
}
else {
appWindow.getCenter().setOpacity(100);
buttonPressed = false;
System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
}
});
loginContainer.addColumn(0, userNameDesc, passwordDesc);
loginContainer.addColumn(1, username, password);
loginContainer.add(logInBtn, 1, 2);
Scene scene = new Scene(appWindow, 300, 250);
stage.setScene(scene);
stage.show();
}
}
가 Gridpane 및 Gridpane 시각 불투명도를 차일에 영향을해야한다 "Log In"단추를 누르면이 작동하지 않는 최소한의 예를 추가 그러나 그렇지 않습니다. 올바른 불투명도 값만 인쇄합니다. documentation 따르면
"커버"가없는 간단한 접근 방식으로 [MCVE]를 만들 수 있습니까? 버튼과 텍스트 필드가있는 컨테이너를 페이드 아웃하면 버튼과 텍스트 필드가 모두 완벽하게 잘립니다. 설명하는 해결 방법은 필요하지 않습니다. –
@James_D는 방금 저에게 맞지 않는 최소한의 예제를 추가했습니다 – Franch
그것은 당신이 묘사하고있는 것의 예제가 아닙니다 (페이드 트랜지션 등은 없습니다).하지만 당신이 설정하고 있기 때문에 원하는 것을하지 않습니다. 범위를 벗어나는 불투명 값. –