Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package testfx;
- import java.sql.*;
- import javafx.application.Application;
- import javafx.beans.property.SimpleStringProperty;
- import javafx.beans.property.StringProperty;
- import javafx.beans.value.ChangeListener;
- import javafx.beans.value.ObservableValue;
- import javafx.event.Event;
- import javafx.event.EventHandler;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.geometry.VPos;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.ListView;
- import javafx.scene.control.PasswordField;
- import javafx.scene.control.ScrollPane;
- import javafx.scene.control.TextArea;
- import javafx.scene.control.TextAreaBuilder;
- import javafx.scene.control.TextField;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.input.MouseEvent;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.layout.StackPane;
- import javafx.scene.layout.VBox;
- import javafx.scene.paint.Color;
- import javafx.scene.text.Font;
- import javafx.scene.text.FontWeight;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.util.Properties;
- import javax.swing.JFrame;
- import javax.swing.SwingUtilities;
- //import com.sun.corba.se.pept.transport.Connection;
- public class HelloWorld extends Application{
- Stage window;
- Scene main, scena1, scena2, scena3, scena_student_wyswietl_oceny,scena_student_proponuj_temat;
- String typ_konta = "brak";
- String sql, imie;
- TextField tfName = new TextField();
- PasswordField pfPwd = new PasswordField();
- Label lblImie = new Label();
- Label lblImie2 = new Label();
- String user,haslo;
- int id;
- Label blad = new Label();
- int ilosc_tematow;
- StringProperty textRecu = new SimpleStringProperty();
- public static void main(String[] args) {
- launch(args);
- }
- public void start(Stage primaryStage) throws Exception{
- window = primaryStage;
- //blad.setBackground(Color.RED);
- GridPane maingrid = new GridPane();
- maingrid.setAlignment(Pos.CENTER);
- maingrid.setHgap(10);
- maingrid.setVgap(12);
- HBox mainButtons = new HBox();
- mainButtons.setSpacing(10.0);
- FileInputStream input = new FileInputStream("resources/images/profesor.png");
- Image image = new Image(input);
- ImageView imageView = new ImageView(image);
- FileInputStream input2 = new FileInputStream("resources/images/student.png");
- Image image2 = new Image(input2);
- ImageView imageView2 = new ImageView(image2);
- FileInputStream input3 = new FileInputStream("resources/images/admin.png");
- Image image3 = new Image(input3);
- ImageView imageView3 = new ImageView(image3);
- Button btn_student = new Button("", imageView2);
- Button btn_wykladowca = new Button("", imageView);
- Button btn_admin = new Button("", imageView3);
- btn_student.setMinWidth(100);
- btn_wykladowca.setMinWidth(100);
- mainButtons.getChildren().addAll(btn_student, btn_wykladowca, btn_admin);
- mainButtons.setAlignment(Pos.CENTER);
- maingrid.add(mainButtons, 0, 2, 2, 1);
- main = new Scene(maingrid, 690,300);
- Label lblName = new Label("Nazwa Użytkownika");
- //TextField tfName = new TextField();
- Label lblPwd = new Label("Hasło");
- btn_student.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(scena1);
- typ_konta = "student";
- lblName.setText("Nr indeksu: ");
- }
- });
- btn_wykladowca.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(scena1);
- typ_konta = "prowadzacy";
- lblName.setText("Email: ");
- }
- });
- btn_admin.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(scena1);
- typ_konta = "admin";
- lblName.setText("Login: ");
- }
- });
- // btn_student.setOnAction(e-> window.setScene(scena1));
- // btn_wykladowca.setOnAction(e-> window.setScene(scena1));
- // btn_admin.setOnAction(e-> window.setScene(scena1));
- GridPane grid = new GridPane();
- grid.setAlignment(Pos.CENTER);
- grid.setHgap(10);
- grid.setVgap(12);
- HBox hbButtons = new HBox();
- hbButtons.setSpacing(10.0);
- HBox backButton = new HBox();
- backButton.setSpacing(10.0);
- Button btnLogin = new Button("Zaloguj");
- Button btnBack = new Button("Cofnij");
- Button btnTest = new Button("Test");
- //PasswordField pfPwd = new PasswordField();
- //Button btnback = new Button();
- backButton.getChildren().addAll(btnBack, btnLogin);
- backButton.setAlignment(Pos.TOP_RIGHT);
- btnBack.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(main);
- pfPwd.clear();
- tfName.clear();
- }
- });
- //btnLogin.setOnAction(e-> window.setScene(main));
- btnLogin.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- // lblName.setText("dyiaaśś");
- user = tfName.getText();
- //try (Connection conn = DriverManager.getConnection(connectionURL, properties)) {
- Connection con = null;
- try {
- //Class.forName("com.mysql.cj.jdbc.Driver");
- con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- if(con!=null) {
- System.out.println("Pomyślnie połączono z bazą daych");
- }
- Statement stmt=con.createStatement();
- if(typ_konta == "student") {
- sql="Select * from student where nr_indeksu='"+user+"'";
- System.out.println(typ_konta);
- }else if(typ_konta == "prowadzacy") {
- sql="Select * from prowadzacy where PR_imie='"+user+"'";
- System.out.println(typ_konta);
- }
- else {
- sql="Select * from admin where Admin_login='"+user+"'";
- System.out.println(typ_konta);
- }
- ResultSet rs=stmt.executeQuery(sql);
- //System.out.println(lblName.getText());
- if(rs.next()) {
- System.out.println("Pomyślnie zalogowano");
- if(typ_konta == "student") {
- try {
- textRecu.setValue("");
- Connection con2 = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- Statement stmt2=con2.createStatement();
- sql="select Stu_imie, STU_nazwisko, STU_haslo from Student where nr_indeksu = '"+user+"'";
- // System.out.println("Test" + user);
- ResultSet rs2=stmt2.executeQuery(sql);
- // if(rs!=null){
- // while (rs.next()){
- if(rs2.next()) {
- imie = rs2.getString(1) +" "+rs2.getString(2);
- haslo = rs2.getString(3);
- //System.out.println(imie);
- // lblImie.setText(imie);
- //System.out.println(pfPwd.getText());
- lblImie.setText(imie);
- lblImie2.setText(imie);
- }
- // }
- con2.close();
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if(pfPwd.getText().equals(haslo)) {
- window.setScene(scena_student_wyswietl_oceny);
- System.out.println("Zalogowano na konto");
- }else {
- System.out.println("Złe hasło");
- }
- }
- // if (typ_konta == "prowadzacy") {
- //
- // }if (typ_konta == "admin") {
- //
- // }
- //lblImie.setText(imie);
- }else {
- System.out.println("zły login");
- }
- con.close();
- }catch(Exception f) {
- System.out.println(f);
- }
- //lblImie.setText(imie);
- }
- });
- // hbButtons.getChildren().addAll(btnTest);
- // btnTest.setDefaultButton(true);
- // hbButtons.setAlignment(Pos.BASELINE_RIGHT);
- // btnTest.setOnAction(e-> window.setScene(scena1));
- grid.add(lblName, 0, 0);
- grid.add(tfName, 1, 0);
- grid.add(lblPwd, 0, 1);
- grid.add(pfPwd, 1, 1);
- grid.add(hbButtons, 0, 2, 2, 1);
- grid.add(backButton, 0, 2, 2, 2);
- //layout1.getChildren().addAll(label1, button1);
- scena1 = new Scene(grid, 690,300);
- scena3 = new Scene(addGridPane(), 1000,600);
- //scena_student = new Scene(student(primaryStage), 1000,600);
- scena_student_wyswietl_oceny = new Scene(Student_wyswietl_oceny(), 1000,600);
- scena_student_proponuj_temat = new Scene(Student_proponuj_temat(), 1000,600);
- Button button0 = new Button("Go to scene 1");
- button0.setOnAction(e-> window.setScene(scena1));
- StackPane layout2 = new StackPane();
- layout2.getChildren().add(button0);
- scena2 = new Scene(layout2, 690,300);
- window.setScene(main);
- window.setTitle("Aplikacja");
- window.show();
- }
- public HBox Student_wyswietl_oceny() {
- blad.setText(" ");
- HBox h = new HBox();
- VBox v = new VBox();
- FileInputStream input = null;
- try {
- input = new FileInputStream("resources/images/student.png");
- } catch (FileNotFoundException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- }
- Image image = new Image(input);
- ImageView imageView = new ImageView(image);
- TextArea field = new TextArea();
- Label margines = new Label();
- //Label lblImie1 = new Label();
- Button btn_stu_1 = new Button("Wyświetl Oceny");
- //btn_stu_1.setOnAction(e -> window.setScene(scena_student_wyswietl_oceny));
- btn_stu_1.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(scena_student_wyswietl_oceny);
- Connection con = null;
- try {
- textRecu.setValue("Przedmioty: " + System.lineSeparator());
- con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- Statement stmt=con.createStatement();
- // sql="select Student.STU_nazwisko, projekt.PRO_ocena from Student,projekt\r\n" +
- // "where Student.ID_studenta = projekt.ID_studenta\r\n" +
- // "AND nr_indeksu='"+user+"'";
- // sql = "select projekty.temat, projekt.PRO_ocena, student.nr_indeksu from Student,projekt, projekty\r\n" +
- // " where Student.ID_studenta = projekt.ID_studenta\r\n" +
- // " AND projekt.ID_projektu = projekty.ID_projektu\r\n" +
- // " AND Student.nr_indeksu = '"+user+"'";
- sql = "select przedmiot.PRZ_nazwa, przedmiot2.PRO_ocena, student.nr_indeksu from Student,przedmiot,przedmiot2 where Student.ID_studenta = przedmiot2.ID_studenta AND przedmiot.ID_przedmiotu = przedmiot2.ID_przedmiotu And student.nr_indeksu = '"+user+"'";
- ResultSet rs=stmt.executeQuery(sql);
- //System.out.println(lblName.getText());
- if(rs!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- while (rs.next()){
- int i = 1;
- String temp = rs.getString(i) +" \t "+rs.getString(i+1) + System.lineSeparator();
- i=i+2;
- textRecu.setValue(textRecu.getValue() +temp);
- //textRecu.setValue(textRecu.getValue() + " Koniec");
- //System.out.println(rs.getString(1) +" \t "+rs.getString(2));
- //System.out.println(textRecu.getValue());
- //lblImie.setText(imie);
- //System.out.println("Tutaj jest moje imie + temat"+imie);
- //+" \t "+rs.getString(4)+" \t "+rs.getString(5)+" \t "+rs.getString(6));
- //System.out.println(rs.getString(2));
- //System.out.println(rs.getString(3));
- }
- }
- textRecu.setValue(textRecu.getValue() + "Projekty: " + System.lineSeparator());
- Statement stmt2=con.createStatement();
- sql ="select projekty.temat, projekt.PRO_ocena, student.nr_indeksu from Student, projekt, projekty where Student.ID_studenta = projekt.ID_studenta and projekt.ID_projektu = projekty.ID_projektu and student.nr_indeksu = '"+user+"'";
- ResultSet rs2=stmt2.executeQuery(sql);
- if(rs2!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- while (rs2.next()){
- int i = 1;
- String temp = rs2.getString(i) +" \t "+rs2.getString(i+1) + System.lineSeparator();
- System.out.println(temp);
- i=i+2;
- textRecu.setValue(textRecu.getValue() +temp);
- }
- }
- con.close();
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- });
- btn_stu_1.setMaxSize(200, 40);
- btn_stu_1.setAlignment(Pos.CENTER);
- Button btn_stu_2 = new Button("Proponuj Temat");
- //btn_stu_2.setOnAction(e -> window.setScene(scena_student_proponuj_temat));
- btn_stu_2.setMaxSize(200, 40);
- btn_stu_2.setAlignment(Pos.CENTER);
- btn_stu_2.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- //==========
- window.setScene(scena_student_proponuj_temat);
- textRecu.setValue(" ");
- blad.setText(" ");
- Connection con2;
- try {
- con2 = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- //id = Integer.parseInt(rs2.getString(4));
- Statement stmt4=con2.createStatement();
- sql="select * from student where nr_indeksu = '"+user+"'";
- ResultSet rs4=stmt4.executeQuery(sql);
- while (rs4.next()){
- id = Integer.parseInt(rs4.getString(4));
- }
- Statement stmt3=con2.createStatement();
- sql="select * from temat_propozycja where ID_studenta = '"+id+"'";
- ResultSet rs3=stmt3.executeQuery(sql);
- if(rs3!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- int i = 1;
- while (rs3.next()){
- String temp = rs3.getString(6) + System.lineSeparator();
- System.out.println(temp);
- i++;
- textRecu.setValue(textRecu.getValue() +temp);
- }
- }
- } catch (SQLException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- }
- //===========
- }
- });
- Button btn_stu_3 = new Button("Wyloguj");
- btn_stu_3.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(main);
- pfPwd.clear();
- tfName.clear();
- }
- });
- // btn_stu_3.setOnAction(e -> window.setScene(main));
- btn_stu_3.setMaxSize(200, 40);
- btn_stu_3.setAlignment(Pos.CENTER);
- v.setSpacing(10.0);
- v.getChildren().addAll(margines,imageView, lblImie, btn_stu_1, btn_stu_2, btn_stu_3);
- v.setAlignment(Pos.TOP_CENTER);
- v.setPrefWidth(300);
- field.setPrefWidth(700);
- h.getChildren().addAll(v, field);
- field.textProperty().bind(textRecu);
- //here you also add listener to the textRecu
- textRecu.addListener(new ChangeListener<Object>() {
- public void changed(ObservableValue<?> observable, Object oldValue,
- Object newValue) {
- // from stackoverflow.com/a/30264399/1032167
- // for some reason setScrollTop will not scroll properly
- //consoleTextArea.setScrollTop(Double.MAX_VALUE);
- field.selectPositionCaret(field.getLength());
- field.deselect();
- }
- });
- return h;
- }
- public HBox Student_proponuj_temat() {
- blad.setText(" ");
- HBox h = new HBox();
- HBox nazwa_tematu = new HBox();
- VBox v = new VBox();
- VBox wynik = new VBox();
- FileInputStream input = null;
- try {
- input = new FileInputStream("resources/images/student.png");
- } catch (FileNotFoundException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- }
- Image image = new Image(input);
- ImageView imageView = new ImageView(image);
- TextArea field = new TextArea();
- Label margines = new Label();
- Label margines2 = new Label();
- Label blad = new Label();
- Label lbl_Temat = new Label();
- lbl_Temat.setText("Zaproponowane Tematy:");
- blad.setText(" ");
- Button btn_stu_1 = new Button("Wyświetl Oceny");
- //btn_stu_1.setOnAction(e -> window.setScene(scena_student_wyswietl_oceny));
- btn_stu_1.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(scena_student_wyswietl_oceny);
- blad.setText(" ");
- Connection con = null;
- try {
- textRecu.setValue("Przedmioty: " + System.lineSeparator());
- con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- Statement stmt=con.createStatement();
- // sql="select Student.STU_nazwisko, projekt.PRO_ocena from Student,projekt\r\n" +
- // "where Student.ID_studenta = projekt.ID_studenta\r\n" +
- // "AND nr_indeksu='"+user+"'";
- // sql = "select projekty.temat, projekt.PRO_ocena, student.nr_indeksu from Student,projekt, projekty\r\n" +
- // " where Student.ID_studenta = projekt.ID_studenta\r\n" +
- // " AND projekt.ID_projektu = projekty.ID_projektu\r\n" +
- // " AND Student.nr_indeksu = '"+user+"'";
- sql = "select przedmiot.PRZ_nazwa, przedmiot2.PRO_ocena, student.nr_indeksu from Student,przedmiot,przedmiot2 where Student.ID_studenta = przedmiot2.ID_studenta AND przedmiot.ID_przedmiotu = przedmiot2.ID_przedmiotu And student.nr_indeksu = '"+user+"'";
- ResultSet rs=stmt.executeQuery(sql);
- //System.out.println(lblName.getText());
- if(rs!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- while (rs.next()){
- int i = 1;
- String temp = rs.getString(i) +" \t "+rs.getString(i+1) + System.lineSeparator();
- i=i+2;
- textRecu.setValue(textRecu.getValue() +temp);
- //textRecu.setValue(textRecu.getValue() + " Koniec");
- //System.out.println(rs.getString(1) +" \t "+rs.getString(2));
- //System.out.println(textRecu.getValue());
- //lblImie.setText(imie);
- //System.out.println("Tutaj jest moje imie + temat"+imie);
- //+" \t "+rs.getString(4)+" \t "+rs.getString(5)+" \t "+rs.getString(6));
- //System.out.println(rs.getString(2));
- //System.out.println(rs.getString(3));
- }
- }
- textRecu.setValue(textRecu.getValue() + "Projekty: " + System.lineSeparator());
- Statement stmt2=con.createStatement();
- sql ="select projekty.temat, projekt.PRO_ocena, student.nr_indeksu from Student, projekt, projekty where Student.ID_studenta = projekt.ID_studenta and projekt.ID_projektu = projekty.ID_projektu and student.nr_indeksu = '"+user+"'";
- ResultSet rs2=stmt2.executeQuery(sql);
- if(rs2!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- while (rs2.next()){
- int i = 1;
- String temp = rs2.getString(i) +" \t "+rs2.getString(i+1) + System.lineSeparator();
- System.out.println(temp);
- i=i+2;
- textRecu.setValue(textRecu.getValue() +temp);
- }
- }
- con.close();
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- });
- btn_stu_1.setMaxSize(200, 40);
- btn_stu_1.setAlignment(Pos.CENTER);
- Button btn_stu_2 = new Button("Proponuj Temat");
- btn_stu_2.setOnAction(e -> window.setScene(scena_student_proponuj_temat));
- btn_stu_2.setMaxSize(200, 40);
- btn_stu_2.setAlignment(Pos.CENTER);
- Button btn_stu_3 = new Button("Wyloguj");
- btn_stu_3.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- window.setScene(main);
- pfPwd.clear();
- tfName.clear();
- }
- });
- //btn_stu_3.setOnAction(e -> window.setScene(main));
- btn_stu_3.setMaxSize(200, 40);
- btn_stu_3.setAlignment(Pos.CENTER);
- TextField tf_nazwa_tematu = new TextField();
- Label lbl_nazwa_tematu = new Label("Temat: ");
- Button btn_nazwa_temat = new Button("Zaproponuj temat");
- btn_nazwa_temat.addEventHandler(MouseEvent.MOUSE_CLICKED,
- new EventHandler<MouseEvent>() {
- @Override public void handle(MouseEvent e) {
- // =========================================================================
- textRecu.setValue(" ");
- blad.setText(" ");
- try {
- Connection con2 = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/uczelnia","root","root");
- Statement stmt2=con2.createStatement();
- sql="select * from student where nr_indeksu = '"+user+"'";
- ResultSet rs2=stmt2.executeQuery(sql);
- while (rs2.next()){
- System.out.println(rs2.getString(1) + " "+ rs2.getString(2) + " "+ rs2.getString(3)+ " "+rs2.getString(4)+ " "+rs2.getString(5)+ " "+rs2.getString(6)+ " "+rs2.getString(7));
- if(tf_nazwa_tematu.getText().equals("")) {
- //System.out.println("Nie Uzupełniono");
- blad.setTextFill(Color.web("#FF0000"));
- blad.setText("Uzupełnij temat");
- }else {
- System.out.println("Uzupełniono");
- blad.setText(" ");
- Statement stmt3=con2.createStatement();
- sql = "SELECT ID_Temat FROM temat_propozycja ORDER BY ID_Temat ASC";
- ResultSet rs3=stmt3.executeQuery(sql);
- while (rs3.next()){
- //System.out.println(rs3.getString(1));
- ilosc_tematow = Integer.parseInt(rs3.getString(1));
- System.out.println(ilosc_tematow);
- }
- //
- //ResultSet rs4=stmt4.executeQuery(sql);
- }
- id = Integer.parseInt(rs2.getString(4));
- System.out.println("a= "+ilosc_tematow);
- ilosc_tematow++;
- System.out.println("b= "+ilosc_tematow);
- Statement stmt4=con2.createStatement();
- sql="INSERT INTO temat_propozycja (ID_Temat ,ID_wydzialu ,ID_kierunku ,ID_grupy ,ID_studenta ,Temat_nazwa ) VALUES ('"+ilosc_tematow+"','"+rs2.getString(1)+"','"+rs2.getString(2)+"','"+rs2.getString(3)+"','"+rs2.getString(4)+"','"+tf_nazwa_tematu.getText()+"')";
- stmt4.executeUpdate(sql);
- }
- Statement stmt3=con2.createStatement();
- sql="select * from temat_propozycja where ID_studenta = '"+id+"'";
- ResultSet rs3=stmt3.executeQuery(sql);
- if(rs3!=null){
- System.out.println("Pomyślnie wyświetlono");
- //textRecu.setValue(textRecu.getValue() +rs);
- while (rs3.next()){
- String temp = rs3.getString(6) + System.lineSeparator();
- //System.out.println(temp);
- textRecu.setValue(textRecu.getValue() +temp);
- }
- }
- con2.close();
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- //=========================================================================
- System.out.println(tf_nazwa_tematu.getText());
- }
- });
- field.setPrefHeight(300);
- field.setPrefWidth(600);
- field.textProperty().bind(textRecu);
- //here you also add listener to the textRecu
- textRecu.addListener(new ChangeListener<Object>() {
- public void changed(ObservableValue<?> observable, Object oldValue,
- Object newValue) {
- // from stackoverflow.com/a/30264399/1032167
- // for some reason setScrollTop will not scroll properly
- //consoleTextArea.setScrollTop(Double.MAX_VALUE);
- field.selectPositionCaret(field.getLength());
- field.deselect();
- }
- });
- wynik.getChildren().addAll(margines2, nazwa_tematu,blad, lbl_Temat, field);
- nazwa_tematu.getChildren().addAll(lbl_nazwa_tematu, tf_nazwa_tematu, btn_nazwa_temat);
- v.setSpacing(10.0);
- v.getChildren().addAll( margines,imageView, lblImie2, btn_stu_1, btn_stu_2, btn_stu_3);
- v.setAlignment(Pos.TOP_CENTER);
- v.setPrefWidth(300);
- h.getChildren().addAll(v, wynik);
- return h;
- }
- public VBox student(Stage primaryStage) throws Exception{
- VBox root = new VBox();
- StringProperty textRecu = new SimpleStringProperty();
- Button btn_stu_1 = new Button("KLIK");
- Button btn_stu_2 = new Button("Go to scene 1");
- Button btn_stu_3 = new Button("Go to scene 1");
- Button btn_stu_4 = new Button("Go to scene 1");
- Button btn_stu_5 = new Button("Go to scene 1");
- Button btn_stu_6 = new Button("Go to scene 1");
- TextArea field = new TextArea();
- HBox btn_student_group = new HBox();
- btn_student_group.setPadding(new Insets(0, 10, 10, 10));
- btn_student_group.setSpacing(10);
- btn_student_group.getChildren().addAll(btn_stu_1, btn_stu_2);
- // root.set
- // root.setTop(btn_student_group);
- // border.setLeft(addVBox());
- btn_stu_1.setOnMouseClicked(new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- //here you change textRecu and not consoleTextArea.textProperty()
- textRecu.setValue(textRecu.getValue() +"New Line\n");
- }
- });
- root.getChildren().addAll(field, btn_student_group);
- field.textProperty().bind(textRecu);
- //here you also add listener to the textRecu
- textRecu.addListener(new ChangeListener<Object>() {
- public void changed(ObservableValue<?> observable, Object oldValue,
- Object newValue) {
- // from stackoverflow.com/a/30264399/1032167
- // for some reason setScrollTop will not scroll properly
- //consoleTextArea.setScrollTop(Double.MAX_VALUE);
- field.selectPositionCaret(field.getLength());
- field.deselect();
- }
- });
- //primaryStage.setScene(new Scene(root, 300, 275));
- return root;
- }
- public GridPane addGridPane() {
- GridPane grid = new GridPane();
- grid.setAlignment(Pos.TOP_LEFT);
- grid.setHgap(12);
- grid.setVgap(12);
- grid.setPadding(new Insets(20, 20, 20, 20));
- // GridPane grid = new GridPane();
- // grid.setHgap(10);
- // grid.setVgap(10);
- // // grid.setPadding(new Insets(0, 10, 0, 10));
- // grid.setPadding(new Insets(0,0,0,0));
- // Category in column 2, row 1
- Button btn_stu_1 = new Button("Go to scene 1");
- // grid.add(btn_stu_1, 1, 1);
- //btn_stu_1.setLayoutX(250);
- //btn_stu_1.setLayoutY(250);
- Button btn_stu_2 = new Button("Go to scene 1");
- //grid.add(btn_stu_2, 1, 2);
- Button btn_stu_3 = new Button("Go to scene 1");
- // grid.add(btn_stu_3, 1, 3);
- Button btn_stu_4 = new Button("Go to scene 1");
- //grid.add(btn_stu_4, 1, 4);
- Button btn_stu_5 = new Button("Go to scene 1");
- //grid.add(btn_stu_5, 1, 5);
- Button btn_stu_6 = new Button("Go to scene 1");
- // grid.add(btn_stu_6, 1, 6);
- TextArea field = new TextArea();
- // Title in column 3, row 1
- // Subtitle in columns 2-3, row 2
- ListView listView = new ListView();
- grid.add(listView,2, 1);
- // House icon in column 1, rows 1-2
- // ImageView imageHouse = new ImageView(
- // new Image(LayoutSample.class.getResourceAsStream("graphics/house.png")));
- // grid.add(imageHouse, 0, 0, 1, 2);
- // // Left label in column 1 (bottom), row 3
- // Text goodsPercent = new Text("Goods\n80%");
- // GridPane.setValignment(goodsPercent, VPos.BOTTOM);
- // grid.add(goodsPercent, 0, 2);
- // Chart in columns 2-3, row 3
- // ImageView imageChart = new ImageView(
- // new Image(LayoutSample.class.getResourceAsStream("graphics/piechart.png")));
- // grid.add(imageChart, 1, 2, 2, 1);
- // // Right label in column 4 (top), row 3
- // Text servicesPercent = new Text("Services\n20%");
- // GridPane.setValignment(servicesPercent, VPos.TOP);
- // grid.add(servicesPercent, 3, 2);
- return grid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement