K
K
Kamio_Mur2018-11-28 16:25:46
Java
Kamio_Mur, 2018-11-28 16:25:46

How to convert a console program into a windowed program with a graphical interface in Java FX?

Here is the code for my working console program.

package com.company;
import java.lang.String;
import java.util.Scanner;
public class Exersise_663 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);        
int x [] = new int[28];        
System.out.println("Введите оценки учеников через пробел:");    
        for (int i = 0; i < 28; i++)
            x[i] = input.nextInt();        
 int dva = 0;
        for (int i = 0; i < 28; i++) {
            if (x[i] <= 2) 
                x[i] = dva;
dva++;}} 
System.out.println(dva>0 ? " Двойки у " + dva + "       человек" : "Двоек нет!"); }}

Now the same program needs to be done with a graphical interface. The program window itself, the rating input field, the button and the result display field, I made in Scene Builder. FXML file, controller and Main are there and filled. Tell me how to process the events of user interaction with the program, so that when ratings are entered in the first field, they are read by the program, then when the button is pressed, the program determines whether there are twos among the entered ratings and, based on this, in the second field it displays either the number of twos or an inscription that they no.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2018-11-28
@Kamio_Mur

You just bind callbacks (onAction) to the necessary interface controls that read the values ​​of your data. Here is a pretty good tutorial for beginners - https://o7planning.org/ru/10623/javafx-tutorial-fo...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question