You are on page 1of 37

NAME : Nandikaa Shanmugam

REGNo.: 19BCE2461

COURSE CODE: CSE1007

FACULTY: Satish CJ
1) Connection to the database:

2) Database:
3)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


HBox root = new HBox();
root.getChildren().add(bt1);
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
4)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");
Button bt5 = new Button("click here");
Button bt6 = new Button("click here");
Button bt7 = new Button("click here");
HBox root = new HBox();
root.getChildren().add(bt1);
root.getChildren().add(bt2);
root.getChildren().add(bt3);
root.getChildren().add(bt4);
root.getChildren().add(bt5);
root.getChildren().add(bt6);
root.getChildren().add(bt7);
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
5)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");
Button bt5 = new Button("click here");
Button bt6 = new Button("click here");
Button bt7 = new Button("click here");
VBox root = new VBox();
root.getChildren().add(bt1);
root.getChildren().add(bt2);
root.getChildren().add(bt3);
root.getChildren().add(bt4);
root.getChildren().add(bt5);
root.getChildren().add(bt6);
root.getChildren().add(bt7);
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
6)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");
Button bt5 = new Button("click here");
Button bt6 = new Button("click here");
Button bt7 = new Button("click here");
FlowPane root = new FlowPane();

root.getChildren().add(bt1);
root.getChildren().add(bt2);
root.getChildren().add(bt3);
root.getChildren().add(bt4);
root.getChildren().add(bt5);
root.getChildren().add(bt6);
root.getChildren().add(bt7);
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

7)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");

GridPane root = new GridPane();

root.add(bt1, 0, 0);
root.add(bt2, 1, 1);
root.add(bt3, 2, 2);
root.add(bt4, 3, 3);

Scene scene = new Scene(root,400,400);


scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

8)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");

GridPane root = new GridPane();

root.add(bt1, 0, 0);
root.add(bt2, 1, 1);
root.add(bt3, 2, 2);
root.add(bt4, 3, 3);
root.setHgap(20);
root.setVgap(20);
root.setGridLinesVisible(true);
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

9)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

Button bt1 = new Button("click here");


Button bt2 = new Button("click here");
Button bt3 = new Button("click here");
Button bt4 = new Button("click here");

BorderPane root = new BorderPane();

root.setBottom(bt1);
root.setCenter(bt2);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

10)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {

//lets create label


Label lb1 = new Label("Enter your name");
HBox root = new HBox();
root.getChildren().add(lb1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

11)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//lets create label


Label lb1 = new Label("Enter your name");
lb1.setText("I am setting some other text");
lb1.setTextFill(Color.RED);
lb1.setFont(new Font("Times New Roman",32));
lb1.setTextAlignment(TextAlignment.CENTER);
HBox root = new HBox();
root.getChildren().add(lb1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

12)
package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//lets create label


Label lb1 = new Label("Enter your name");
lb1.setText("I am setting some other text and this text is
large text & i dont think it will fit");
lb1.setWrapText(true);
lb1.setTextFill(Color.RED);
lb1.setFont(new Font("Times New Roman",32));
lb1.setTextAlignment(TextAlignment.CENTER.JUSTIFY);
HBox root = new HBox();
root.getChildren().add(lb1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

13)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//lets create label


FileInputStream name = new
FileInputStream("C:\\nandikaa\\college\\flower.jpg");
Image img = new Image(name);
ImageView imgview = new ImageView(img);
Label lb1 = new Label("Enter your name",imgview);
lb1.setText("I am setting some other text and this text is
large text & i dont think it will fit");
lb1.setWrapText(true);
lb1.setTextFill(Color.RED);
lb1.setFont(new Font("Times New Roman",32));
lb1.setTextAlignment(TextAlignment.CENTER.JUSTIFY);
HBox root = new HBox();
root.getChildren().add(lb1);

Scene scene = new Scene(root,2000,2000);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
14)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//this is a demo for creating button control


Button bt1 = new Button("click here");
bt1.setText("I am setting my text here");
HBox root = new HBox(bt1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
15)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//this is a demo for creating button control


Button bt1 = new Button("click here");
bt1.setText("I am setting my text here and this is some long
text we will have on the button");
bt1.setWrapText(true);
bt1.setDisable(true);
HBox root = new HBox(bt1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
16)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//this is a demo for creating button control


//how to add image

FileInputStream name = new


FileInputStream("C:\\nandikaa\\college\\flower.jpg");
Image img = new Image(name);
ImageView imgview = new ImageView(img);

Button bt1 = new Button("click here",imgview);


HBox root = new HBox(bt1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}

17)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for radio button


ToggleGroup group = new ToggleGroup();
RadioButton op1 = new RadioButton("English");
RadioButton op2 = new RadioButton("Physics");
RadioButton op3 = new RadioButton("Chemistry");
RadioButton op4 = new RadioButton("Maths");
op1.setToggleGroup(group);
op2.setToggleGroup(group);
op3.setToggleGroup(group);
op4.setToggleGroup(group);

VBox root = new VBox();

root.getChildren().addAll(op1,op2,op3,op4);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

18)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for check box in javafx


CheckBox op1 = new CheckBox("English");
CheckBox op2 = new CheckBox("Physics");
CheckBox op3 = new CheckBox("Biology");
CheckBox op4 = new CheckBox("Maths");

VBox root = new VBox();

root.getChildren().addAll(op1,op2,op3,op4);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

19)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for hyperlink in javafx


Hyperlink y1 = new
Hyperlink("https://www.youtube.com/watch?v=N5pP7k7qppE");
VBox root = new VBox(y1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

20)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for combo box


ComboBox<String> subjects = new ComboBox<String>();
subjects.getItems().add("English");
subjects.getItems().add("Physics");
subjects.getItems().add("Chemistry");
subjects.getItems().add("Maths");

HBox root = new HBox(subjects);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}
21)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for textfield

TextField name = new TextField();


PasswordField pass = new PasswordField();
VBox root = new VBox();
root.getChildren().addAll(name,pass);

Scene scene = new Scene(root,400,400);


scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

22)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {
//demo for textfield

TextField name = new TextField();


name.setMaxWidth(300);
PasswordField pass = new PasswordField();
pass.setMaxWidth(300);
VBox root = new VBox();
root.getChildren().addAll(name,pass);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

23)
package application;

import java.io.FileInputStream;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for event


Button bt1 = new Button("click here");
Label lb1 = new Label();

bt1.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
lb1.setText("you have clicked that button");
}
});

HBox root = new HBox();


root.getChildren().addAll(bt1,lb1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

24)
package application;
import java.io.FileInputStream;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

public class Main extends Application {


@Override
public void start(Stage primaryStage) {
try {

//demo for reading input from textfield


TextField name = new TextField();
name.setMaxWidth(300);
Button bt1 = new Button("click here");
Label lb1 = new Label();

bt1.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
lb1.setText("Welcome Ms. "+name.getText());
lb1.setTextFill(Color.DARKGREEN);
lb1.setFont(new Font("Times new Roman",23));
}
});

VBox root = new VBox();


root.getChildren().addAll(name,bt1,lb1);

Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExte
rnalForm());
primaryStage.setHeight(500);
primaryStage.setWidth(500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


launch(args);
}
}

25)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("connection is successful");
Statement stmt = con.createStatement();
stmt.executeUpdate("update student set address='Korea' where
name='nandikaa';");
System.out.println("Record updated successfully");
stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}
26)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("connection is successful");
Statement stmt = con.createStatement();
stmt.executeUpdate("Delete from student where name='Tom';");
System.out.println("Record deleted successfully");
stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}
27)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println(" Database connection is Established");
Statement stmt = con.createStatement();
ResultSet rs= stmt.executeQuery("select * from student;");
while(rs.next())
{

System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getSt
ring(4));
}
stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}
28)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("Database connection is Established");
Statement stmt = con.createStatement();
ResultSet rs= stmt.executeQuery("select * from student;");
if(rs.next()==false)
{
System.out.println("The table is empty");
}
else
{
while(rs.next())
{

System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getSt
ring(4));
}
}

stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}}}
29)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("Database connection is Established");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs= stmt.executeQuery("select * from student;");
if(rs.next()==false)
{
System.out.println("The table is empty");
}
else
{
rs.previous();
while(rs.next())
{

System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getSt
ring(4));
}
}

stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}}
30)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("Database connection is Established");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs= stmt.executeQuery("select * from student where
name='nandikaa';");
if(rs.next()==false)
{
System.out.println("The table is empty");
}
else
{
rs.previous();
while(rs.next())
{

System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getSt
ring(4));
}
}

stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}}

31)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("Database connection is Established");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs= stmt.executeQuery("select * from student where
name='Harini';");
if(rs.next()==false)
{
System.out.println("No such record found in the
database");
}
else
{
rs.previous();
while(rs.next())
{

System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getSt
ring(4));
}
}

stmt.close();
con.close();

}
catch(SQLException e){
System.out.println(e.getMessage());

}}}

32)
package java_sql;
import java.util.*;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;

import com.sun.jdi.connect.spi.Connection;

public class firstsql {

public static void main(String[] args) throws ClassNotFoundException,


IOException {
try {
//connecting java to database
java.sql.Connection con=null;
Class.forName("com.mysql.cj.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/vit","root","");
System.out.println("Database Connection established Successfully");
Scanner input = new Scanner(System.in);
Scanner input_str = new Scanner(System.in);
System.out.println("Enter your name");
String name = input.nextLine();
System.out.println("Enter your address");
String address = input.nextLine();
System.out.println("Enter your phone");
int phone = input.nextInt();
System.out.println("Enter your emailid");
String emailid = input_str.nextLine();
String sq1 = "insert into student values(?,?,?,?);";
PreparedStatement stmt = con.prepareStatement(sq1);
stmt.setString(1, name);
stmt.setString(2, address);
stmt.setInt(3, phone);
stmt.setString(4, emailid);
stmt.execute();

stmt.close();
con.close();
System.out.println("Database updated!!");
}
catch(SQLException e){
System.out.println(e.getMessage());

You might also like