Skip to content

Commit

Permalink
Cleanup and format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
besidev committed Jan 17, 2023
1 parent 3649a85 commit 54027a2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 42 deletions.
22 changes: 15 additions & 7 deletions src/main/java/com/jpro/hellojpro/HelloJPro.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@
import javafx.scene.text.Font;
import javafx.stage.Stage;

/**
* Hello JPro application.
*
* @author Florian Kirmaier
*/
public class HelloJPro extends Application {

public static void main(String[] args)
{
launch(args);
}

@Override
public void start(Stage stage)
{
public void start(Stage stage) {
Label label = new Label("Hello JPro!");
label.setFont(new Font(50));
label.setAlignment(Pos.CENTER);
stage.setScene(new Scene(label));
stage.show();
}

/**
* Application entry point.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
39 changes: 22 additions & 17 deletions src/main/java/com/jpro/hellojpro/HelloJProFXML.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,42 @@

import java.io.IOException;

public class HelloJProFXML extends JProApplication
{
public static void main(String[] args)
{
launch(args);
}
/**
* Hello JPro application using FXML.
*
* @author Florian Kirmaier
*/
public class HelloJProFXML extends JProApplication {

@Override
public void start(Stage stage)
{
//load user interface as FXML file
public void start(Stage stage) {
// load user interface as FXML file
FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/jpro/hellojpro/fxml/HelloJPro.fxml"));
Scene scene = null;
try
{
try {
Parent root = loader.load();
HelloJProFXMLController controller = loader.getController();
controller.init(this);

//create JavaFX scene
// create JavaFX scene
scene = new Scene(root);
}
catch (IOException e)
{
} catch (IOException e) {
e.printStackTrace();
}

stage.setTitle("Hello jpro!");
stage.setTitle("Hello JPro!");
stage.setScene(scene);

//open JavaFX window
// open JavaFX window
stage.show();
}

/**
* Application entry point.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
32 changes: 14 additions & 18 deletions src/main/java/com/jpro/hellojpro/HelloJProFXMLController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
import java.util.ResourceBundle;

/**
* Created by TB on 25.02.16.
* Hello JPro FXML controller.
*
* @author Florian Kirmaier
*/
public class HelloJProFXMLController implements Initializable
{
public class HelloJProFXMLController implements Initializable {

@FXML
public Label platformLabel;

@FXML
protected StackPane root;

@FXML
protected Node logo;

protected JProApplication jProApplication;

protected JProApplication jproApplication;
protected ParallelTransition pt;


@Override
public void initialize(URL location, ResourceBundle resources)
{
public void initialize(URL location, ResourceBundle resources) {
platformLabel.setText(String.format("Platform: %s", WebAPI.isBrowser() ? "Browser" : "Desktop"));
}

protected void initLogoAnimation(Node logo)
{
protected void initLogoAnimation(Node logo) {
ScaleTransition st = new ScaleTransition(Duration.millis(1000), logo);
st.setByX(-0.5);
st.setByY(-0.5);
Expand All @@ -56,17 +56,13 @@ protected void initLogoAnimation(Node logo)
pt = new ParallelTransition(st, ft);
pt.play();

if(WebAPI.isBrowser()) {
jProApplication.getWebAPI().addInstanceCloseListener(() -> {
pt.stop();
});
if (WebAPI.isBrowser()) {
jproApplication.getWebAPI().addInstanceCloseListener(() -> pt.stop());
}
}


public void init(JProApplication jProApplication)
{
this.jProApplication = jProApplication;
protected void init(JProApplication jproApplication) {
this.jproApplication = jproApplication;
initLogoAnimation(this.logo);
}
}

0 comments on commit 54027a2

Please sign in to comment.