96 lines
5.4 KiB
HTML
96 lines
5.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>HandleClickEvent.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}
|
|
.ST2 {font-family: monospace; font-weight: bold; font-style: italic}
|
|
.ST0 {color: #287bde}
|
|
.string {color: #6a8759}
|
|
.ST1 {color: #ffc66d}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
.ST3 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
|
|
.ST4 {color: #9876aa; 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/HandleClickEvent.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.event.ActionEvent;
|
|
<span class="literal">import</span> javafx.event.EventHandler;
|
|
<span class="literal">import</span> javafx.scene.Scene;
|
|
<span class="literal">import</span> javafx.scene.control.Button;
|
|
<span class="literal">import</span> javafx.scene.layout.BorderPane;
|
|
<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">Pane</span><span class="comment">;</span>
|
|
<span class="literal">import</span> javafx.stage.Stage;
|
|
<span class="literal">import</span> style.ButtonStyle;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">Athanasios</span> <span class="comment">V</span><span class="comment">.</span> <span class="comment">Markou</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> HandleClickEvent <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
|
|
{
|
|
Button buttonOK = <span class="literal">new</span> Button(<span class="string">"</span><span class="string">OK</span><span class="string">"</span>);
|
|
buttonOK.setStyle(ButtonStyle.<span class="ST2">getStyle</span>());
|
|
<span class="ST2">OKHandlerClass</span> eventHnadlerOK = <span class="literal">new</span> OKHandlerClass();
|
|
buttonOK.setOnAction(eventHnadlerOK);
|
|
|
|
Button buttonCancel = <span class="literal">new</span> Button(<span class="string">"</span><span class="string">Cancel</span><span class="string">"</span>);
|
|
buttonCancel.setStyle(ButtonStyle.<span class="ST2">getStyle</span>());
|
|
<span class="ST2">CancelHandlerClass</span> eventHandlerCancel = <span class="literal">new</span> CancelHandlerClass();
|
|
buttonCancel.setOnAction(eventHandlerCancel);
|
|
|
|
|
|
BorderPane pane = <span class="literal">new</span> BorderPane();
|
|
pane.setTop(buttonOK);
|
|
pane.setBottom(buttonCancel);
|
|
Scene scene = <span class="literal">new</span> Scene( pane);
|
|
primaryStage.setScene(scene);
|
|
primaryStage.show();
|
|
|
|
}
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args)
|
|
{
|
|
<span class="ST2">launch</span>( args);
|
|
}
|
|
|
|
<span class="literal">private</span> <span class="literal">static</span> <span class="literal">class</span> <span class="ST2">OKHandlerClass</span> <span class="literal">implements</span> EventHandler<ActionEvent> {
|
|
|
|
@Override
|
|
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">handle</span>(ActionEvent event) {
|
|
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">You clicked OK!</span><span class="string">"</span>);
|
|
}
|
|
}
|
|
|
|
<span class="literal">private</span> <span class="literal">static</span> <span class="literal">class</span> <span class="ST2">CancelHandlerClass</span> <span class="literal">implements</span> EventHandler<ActionEvent> {
|
|
|
|
@Override
|
|
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">handle</span>(ActionEvent event) {
|
|
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">You clicked Cancel!</span><span class="string">"</span>);
|
|
}
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|