응용 프로그램을 닫을 때 호출되는이 간단한 대화 상자가 있습니다.이 대화 상자를 개선하는 방법
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class test extends Application
{
public static void main(String[] args)
{
Application.launch(args);
}
@Override
public void start(Stage primaryStage)
{
// Image
Image image = new Image("http://docs.oracle.com/javafx/"
+ "javafx/images/javafx-documentation.png");
ImageView imageView = new ImageView();
imageView.setImage(image);
// Text
Text t = new Text();
t.setText("This is a text sample");
// Buttons
Button btnYes = new Button("Yes");
Button btnNo = new Button("No");
// Buttons layout
HBox hbox = new HBox(8); // spacing = 8
hbox.setStyle("-fx-padding: 15; -fx-font-size: 15pt;");
hbox.getChildren().addAll(btnYes, btnNo);
hbox.setAlignment(Pos.BASELINE_RIGHT);
////////////////////////
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10, 20, 10, 20));
//Button btnTop = new Button("Top");
bp.setTop(null);
//Button btnLeft = new Button("Left");
bp.setLeft(imageView);
//Button btnCenter = new Button("Center");
bp.setCenter(t);
//Button btnRight = new Button("Right");
bp.setRight(null);
//Button btnBottom = new Button("Bottom");
bp.setBottom(hbox);
Scene scene = new Scene(bp, 500, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
}
지금까지 그것은 다음과 같습니다
나는 그것을 같이 할 수 있도록합니다 :
당신은 방법을 개선하는 데 도움이 수 버튼의 시각적 인 레이아웃? 이 버튼을 예제처럼 보이게하고 배경색 그라디언트를 설정하는 방법을 모르겠습니다.
SceneBuilder를 사용하십시오. [CSS가있는 FX 스타일 단추] (http://fxexperience.com/2011/12/styling-fx-buttons-with-css/)를 참조하십시오. –
ControlsFX에서 이미지를 복사 했으므로 오픈 소스이므로 코드도 복사하십시오. –