2014-11-17 2 views
0

Итак, я просмотрел несколько вопросов, похожих на мои, но исправления, которые сработали для них, все равно не отобразили окно для меня. Я пытаюсь создать экран входа в систему, это сгенерированный код, и я скопировал общественности статической основной из предыдущих вопросов, но он по-прежнему отображается только окно маленького размера с ничего в нем:JformDesigner-Eclipse 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 
} 

ответ

1

Вы создание и настройка панели содержимого - LoginJ, но не присвоение ее кадру. В конце initComponents метода, вы должны сделать:

this.setContentPane(this.LoginJ); 

Вы увидите свои элементы формы, а затем вы можете настроить, например, увеличьте и центрируйте диалог.

Смежные вопросы