Transform System.out.println to enter it in the graphic part

0

Good friends programmers, I have a situation: I am transforming a program that uses System.out.println to print on the screen and I must convert it into its consequent graphic part.

Part of the code that I need to transform is:

public int getCart(int num) {
        PantallaJuego pj = new PantallaJuego();
        int getCart = 0;
        switch (num) {
            case 0: //Valor del arreglo

                System.out.println("1");//carta a imprimir
                getCart = 1; //Es el valor temporal para asignar para la suma 
                break;
            case 1: //Valor del arreglo
                System.out.println("2");//carta a imprimir
                getCart = 2; //Es el valor temporal para asignar para la suma 
                break;
            case 2:
                System.out.println("3");
                getCart = 3;
                break;

But I need to take those outputs and enter them in JLabel , how could I transform it?

I appreciate the suggestions!

    
asked by Felix mejias 13.11.2018 в 22:36
source

1 answer

0

You can have the System.out.print("") replaced by JOptionPane.show.MessageDialog(null,"") and in general other types of dialogs such as data entry. Or you could also use JFrame and create a custom window with JLabel, JTextField, and JButton.

Example of JOptionPane: here

    
answered by 13.11.2018 / 22:54
source