0

そのため、私と同様の質問をいくつか確認しましたが、それらに有効な修正を行ってもウィンドウが表示されませんでした。ログイン画面を作成しようとしています。これは生成されたコードで、以前の質問から public static main をコピーしましたが、まだ何も表示されていない最小サイズのウィンドウしか表示されません。

package surveyducky;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import com.jgoodies.forms.factories.*;

public class LoginForm extends JFrame{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public LoginForm() {
        initComponents();
        pack();
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                 LoginForm GUI = new LoginForm();
                 GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 GUI.setVisible(true);
            }
        });
    }
    private void submitActionPerformed(ActionEvent e) {
        // TODO add your code here
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - Tamara Turton
        DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance();
        LoginJ = new JPanel();
        panel1 = new JPanel();
        titel = compFactory.createTitle("Welcome to Survey Ducky!");
        userlabel = new JLabel();
        email = new JTextField();
        passlabel = new JLabel();
        password = new JPasswordField();
        vSpacer1 = new JPanel(null);
        submit = new JButton();
        forgotpass = new JButton();
        createacc = new JButton();

        //======== LoginJ ========
        {   
            // JFormDesigner evaluation mark
            LoginJ.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                    "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                    javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
                    java.awt.Color.red), LoginJ.getBorder())); LoginJ.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

            LoginJ.setLayout(new GridBagLayout());
            ((GridBagLayout)LoginJ.getLayout()).columnWidths = new int[] {0, 163};
            ((GridBagLayout)LoginJ.getLayout()).rowHeights = new int[] {50, 43, 27, 47, 25, 0, 54, 0, 0, 0};
            ((GridBagLayout)LoginJ.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

            //======== panel1 ========
            {
                panel1.setLayout(new GridBagLayout());
                ((GridBagLayout)panel1.getLayout()).columnWidths = new int[] {353};
                ((GridBagLayout)panel1.getLayout()).rowHeights = new int[] {0, 0, 0};
                ((GridBagLayout)panel1.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0E-4};

                //---- titel ----
                titel.setFont(new Font("Brush Script MT", Font.BOLD, 30));
                panel1.add(titel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0), 0, 0));
            }
            LoginJ.add(panel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));

            //---- userlabel ----
            userlabel.setText("Username:");
            userlabel.setLabelFor(email);
            LoginJ.add(userlabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));
            LoginJ.add(email, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));

            //---- passlabel ----
            passlabel.setText("Password:");
            passlabel.setLabelFor(password);
            LoginJ.add(passlabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));
            LoginJ.add(password, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));
            LoginJ.add(vSpacer1, new GridBagConstraints(0, 5, 1, 2, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 5), 0, 0));

            //---- submit ----
            submit.setText("Submit");
            submit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    submitActionPerformed(e);
                    submitActionPerformed(e);
                }
            });
            LoginJ.add(submit, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));

            //---- forgotpass ----
            forgotpass.setText("Forgot Password?");
            LoginJ.add(forgotpass, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0), 0, 0));

            //---- createacc ----
            createacc.setText("Create Account");
            LoginJ.add(createacc, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                new Insets(0, 0, 0, 0), 0, 0));
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - Tamara Turton
    private JPanel LoginJ;
    private JPanel panel1;
    private JLabel titel;
    private JLabel userlabel;
    private JTextField email;
    private JLabel passlabel;
    private JPasswordField password;
    private JPanel vSpacer1;
    private JButton submit;
    private JButton forgotpass;
    private JButton createacc;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
4

1 に答える 1