You are on page 1of 7

Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Total Marks: 04

Obtained Marks:

Introduction to
Software Development
Assignment # 01

Submitted To: Sir Zubair Ahmed

Student Name: Zulqarnain Ishfaq

Reg Number: 1612195

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Main
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class Main extends Application {

public static void main(String[] args) {


launch(args);

@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader=new FXMLLoader(Main.class.getResource("/view/Login.fxml"));
AnchorPane pane=loader.load();
Scene scene =new Scene(pane);
primaryStage.setScene(scene);
primaryStage.show();

}
}

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

MainController
package controller;
import javafx.scene.Scene;
import javafx.scene.control.*;
import java.io.IOException;
import application.Main;
import javafx.event.ActionEvent;
import javafx.fxml.*;
import javafx.scene.control.PasswordField;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class MainController {

@FXML
private TextField user;

@FXML
private PasswordField password;

@FXML
private Label status;

public void Login(ActionEvent event) throws IOException


{
if(user.getText().equals("user1")&& password.getText().equals("pas")) {
status.setText("Login Success");

Stage primaryStage=new Stage();


FXMLLoader loader=new FXMLLoader(Main.class.getResource("/view/Main.fxml"));
AnchorPane pane=loader.load();
Scene scene =new Scene(pane);
primaryStage.setScene(scene);
Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB
Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

primaryStage.show();
}else
{
status.setText("Login Failed");
} }}

Login.fxml
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane prefHeight="450.0" prefWidth="500.0"


xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="controller.MainController">
<children>
<Button layoutX="216.0" layoutY="308.0" mnemonicParsing="false"
onAction="#Login" prefHeight="33.0" prefWidth="86.0" text="Login!" />
<TextField fx:id="user" layoutX="190.0" layoutY="146.0" />
<PasswordField fx:id="password" layoutX="190.0" layoutY="200.0" />
<Label fx:id="status" layoutX="16.0" layoutY="94.0" prefHeight="17.0"
prefWidth="432.0" text="Status" textFill="#079e2f" />
<Text layoutX="104.0" layoutY="163.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Username" wrappingWidth="67.291015625" />
<Text layoutX="104.0" layoutY="217.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Password" wrappingWidth="67.2910138964653" />
<Text fill="#ab5959" fontSmoothingType="LCD" layoutX="138.0" layoutY="89.0"
strokeWidth="0.0" text="LOGIN" wrappingWidth="235.00000244379044">
<font>
<Font size="48.0" />
</font>
</Text>
</children>
</AnchorPane>

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Main.fxml
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane prefHeight="450.0" prefWidth="500.0" xmlns:fx="http://javafx.com/fxml/1"


xmlns="http://javafx.com/javafx/9.0.1">
<children>
<Text fill="#6f2b2b" fontSmoothingType="LCD" layoutX="84.0" layoutY="148.0"
stroke="#3c1010" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to your Home
Page" wrappingWidth="317.953125">
<font>
<Font size="37.0" />
</font>
</Text>
</children>
</AnchorPane>

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Intro. Software Dev. BSC/BS-5(A) SZABIST-ISB

You might also like