87 lines
5.6 KiB
HTML
87 lines
5.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>ImageArray2.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
|
.literal {color: #cc7832}
|
|
.ST3 {font-family: monospace; font-weight: bold; font-style: italic}
|
|
.ST0 {color: #287bde}
|
|
.string {color: #6a8759}
|
|
.number {color: #6897bb}
|
|
.ST1 {color: #ffc66d}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
.ST2 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/lab2_FX2_F22_part1/src/lab2_fx2_f22_part1/ImageArray2.java</td></tr></table>
|
|
<pre>
|
|
<span class="comment">/*</span>
|
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
|
<span class="comment"> */</span>
|
|
<span class="literal">package</span> lab2_fx2_f22_part1;
|
|
|
|
<span class="literal">import</span> javafx.application.Application;
|
|
<span class="literal">import</span> javafx.geometry.Insets;
|
|
<span class="literal">import</span> javafx.scene.Scene;
|
|
<span class="literal">import</span> javafx.scene.image.ImageView;
|
|
<span class="comment">import</span> <span class="comment">javafx</span><span class="comment">.</span><span class="comment">scene</span><span class="comment">.</span><span class="comment">layout</span><span class="comment">.</span><span class="comment">HBox</span><span class="comment">;</span>
|
|
<span class="literal">import</span> javafx.scene.layout.Pane;
|
|
<span class="literal">import</span> javafx.scene.layout.VBox;
|
|
<span class="literal">import</span> javafx.stage.Stage;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> ImageArray2 <span class="literal">extends</span> Application {
|
|
|
|
@Override
|
|
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">start</span>(Stage primaryStage) <span class="literal">throws</span> Exception {
|
|
<span class="literal">final</span> String BASE_PATH = <span class="string">"</span><span class="string">image/flag</span><span class="string">"</span>;
|
|
ImageView[] images = <span class="literal">new</span> ImageView[] {
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">0.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">1.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">2.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">3.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">4.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">5.gif</span><span class="string">"</span>),
|
|
<span class="literal">new</span> ImageView(BASE_PATH+<span class="string">"</span><span class="string">6.gif</span><span class="string">"</span>)
|
|
};
|
|
|
|
<span class="comment">// Create a pane to hold the image views</span>
|
|
Pane vb = <span class="literal">new</span> VBox(<span class="number">1</span><span class="number">0</span>);
|
|
vb.setPadding(<span class="literal">new</span> Insets(<span class="number">5</span>, <span class="number">5</span>, <span class="number">5</span>, <span class="number">5</span>));
|
|
|
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">7</span>; ++i) {
|
|
images[i].setFitWidth(<span class="number">1</span><span class="number">50</span>);
|
|
images[i].setFitHeight(<span class="number">1</span><span class="number">00</span>);
|
|
vb.getChildren().add(images[i]);
|
|
}
|
|
<span class="comment">// Create a scene and place it in the stage</span>
|
|
Scene scene = <span class="literal">new</span> Scene(vb);
|
|
primaryStage.setTitle(<span class="string">"</span><span class="string">Flags</span><span class="string">"</span>); <span class="comment">// Set the stage title</span>
|
|
primaryStage.setScene(scene); <span class="comment">// Place the scene in the stage</span>
|
|
primaryStage.show();
|
|
}
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args) {
|
|
<span class="ST3">launch</span>(args);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|