0

I'm trying to use SpringUtilities.makeGrid() in java, to create the interface of a Form, I've read that it should be linked to the source that is in the Oracle documentation but online I haven't found anything, and it keeps returning the error "Syntax error on token "makeGrid"", would anyone be able to help me?

package FrontEnd.Panel;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import FrontEnd.Interface.setButton;

import javax.swing.*;
import java.awt.*;

public class FormPanel extends JPanel implements ActionListener, setButton {

    JLabel labelForForm[];
    JTextField textFieldForForm[];

    public FormPanel() {

        labelForForm = new JLabel[4];

        textFieldForForm = new JTextField[3];

        createFormElements();

        setLayout(new SpringLayout());
        setVisible(true);
        setBorder(BorderFactory.createLineBorder(Color.RED));
    }

    SpringUtilities.makeGrid(
        
    );

    public void createFormElements() {

        String[] labelText = { "Inserisci nome", "Inserisci cognome", "Inserisci data di nascita",
                "Seleziona reparto" };

        String titleForm = "Digita i dati richiesti";

        for (int i = 0; i < labelForForm.length; i++) {

            labelForForm[i] = new JLabel(labelText[i]);

            if (i < labelForForm.length - 1) {
                textFieldForForm[i] = new JTextField(16);

                add(textFieldForForm[i]);

            } else {

            }

            add(labelForForm[i]);
            
        }

        setFormElements();
    }
    
    public void setFormElements() {
    }
        

    @Override
    public void setButton() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        
    }
    
}

mirkzx
  • 1
  • 1
  • Does this result from a quick google search help? https://stackoverflow.com/questions/13165954/springutilities-cannot-be-resolved – Thomas Nov 22 '22 at 12:49
  • The problem is that you have a method call at a place where only a declaration is permitted. (It doesn't help that you have neither imported the class or supplied the required argument for `SpringUtilities.makeGrid`. You will get those errors when you fix the syntax error by putting the `nakeGrid` call inside some method or constructor.) – Stephen C Nov 22 '22 at 13:01

0 Answers0