패딩 : 안쪽 여백, 해당 컨테이너의 setPadding() 메소드 사용

마진 : 바깥쪽 여백, 바깥 컨테이너의 setMargin() 메소드 사용

 

패딩과 마진 적용

package sec03.exam03_margin_padding;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class AppMain extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {
		//패딩 설정 (안쪽 여백)
/*		HBox hbox = new HBox();
 		hbox.setPadding(new Insets(50, 10, 10, 50));
		Button button = new Button();
		button.setPrefSize(100, 100); */
		
		//마진 설정 (바깥 여백)
		HBox hbox = new HBox();
		Button button = new Button();
		button.setPrefSize(100, 100);
		HBox.setMargin(button, new Insets(10, 10, 50, 50));
		
		hbox.getChildren().add(button);
		Scene scene = new Scene(hbox); //장면 생성
		
		primaryStage.setTitle("AppMain"); //윈도우 창 제목 설정"
		primaryStage.setScene(scene); //윈도우 창에 장면 설정
		primaryStage.show(); //윈도우 창 보여주기
	}		
	
	
	public static void main(String[] args) {
		launch(args);
	}
}

+ Recent posts