Java语言程序设计(基础篇)十四章习题 显示图像

package 我要吐了x2;
import java.io.File;

import javafx.application.Application;
import javafx.scene.text.Font;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.*;
import javafx.scene.control.*;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.FontPosture;
public class ShowFourPictures extends Application{

public static void main(String[] args) {
// TODO Auto-generated method stub
File file=new File("Image/ca.gif");
System.out.println(file.getAbsolutePath());//和你系统目录对比 调整你的相对路径
Application.launch();
}
private HBox getHBox() {
HBox hBox=new HBox();
hBox.setPadding(new Insets(15,15,15,15));
hBox.setStyle("-fx-background-color:gold");
ImageView imageView1=new ImageView(new Image("image/凤姐.jpg"));
ImageView imageView2=new ImageView(new Image("image/凤姐.jpg"));
hBox.getChildren().addAll(imageView1,imageView2);
return hBox;
}
private HBox getHBox2() {
HBox hBox=new HBox();
hBox.setPadding(new Insets(15,15,15,15));
hBox.setStyle("-fx-background-color:gold");
ImageView imageView1=new ImageView(new Image("image/凤姐.jpg"));
ImageView imageView2=new ImageView(new Image("image/ca.gif"));
hBox.getChildren().addAll(imageView1,imageView2);
return hBox;
}
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
BorderPane pane=new BorderPane();
pane.setTop(getHBox());
pane.setBottom(getHBox2());
Scene scene=new Scene(pane);
primaryStage.setTitle("Fou fengjie");
primaryStage.setScene(scene);
primaryStage.show();
}

}

前面的导入的类有些多了。是之前做题复制过去的,懒得删除了。

效果如图


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值