Question: Create a simple GUI program using java FX Instructions: The GUI interface should have one label and four buttons. Each button should have a function;
Create a simple GUI program using java FX
Instructions:
The GUI interface should have one label and four buttons. Each button should have a function;
Uppercase Button: the contents of the label will switch to uppercase.
Lowercase Button: the contents of the label will switch to lowercase.
New Phrase Button: will get the user input from the dialog box and place the user input into the label. The case changing buttons should be able to also alter the case of the new phrase.
Reset button will restore everything back to original.
Here is the code I have so far:
LowerButton.java
package helloworld;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ChoiceDialog;
import java.util.Optional;
import java.util.*;
public LowerButton extends Application{
//grid pane layout to be used probably in the main method
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
}
HelloWorld.java
package helloworld; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage;
import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.ButtonType; import javafx.scene.control.TextInputDialog; import javafx.scene.control.ChoiceDialog;
import java.util.Optional; import java.util.*; public class HelloWorld extends Application{ public static void main(String[] args){ launch(args); } @Override
public void start(Stage primaryStage) { Alert al = new Alert(AlertType.INFORMATION); al.setTitle("Alert Title"); al.setHeaderText("Alert Header"); al.setContentText("Alert Context"); al.show();
Alert confirm = new Alert(AlertType.CONFIRMATION); confirm.setTitle( "Hello World!!!!!!!" ); confirm.setHeaderText( "Hello World" ); confirm.setContentText( "Are you sure you wish to engage the self destruct option?" ); Optional< ButtonType > result = confirm.showAndWait(); // all of this is wrong and just me messing aroujnd trying to work my way thrrogh if(button c += i ++ %){ System.out.println("Javier's baby is weird"); } else{ return btn; }
primaryStage.setTitle("Hello World!"); Button btn = new Button();
btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
