Chaque fois que j'exécute ceci, il affiche Build Successful. Mais aucune sortie n'est affichée. J'ai essayé de configurer la classe principale du projet, mais cela n'a pas fonctionné. Y a-t-il quelque chose à revérifier dans ce code? J'ai collé tout le code btw.

    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JOptionPane;
    import javax.swing.Timer;
    import static sun.management.snmp.jvminstr.JvmThreadInstanceEntryImpl.ThreadStateMap.Byte0.runnable;
    public class loginPanel extends javax.swing.JPanel {

    public loginPanel() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jEmailField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPasswordField = new javax.swing.JPasswordField();
        jSeparator2 = new javax.swing.JSeparator();
        showPassword = new javax.swing.JCheckBox();
        jSignIn = new javax.swing.JButton();
        jRegister = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        jPanel1Label3 = new javax.swing.JLabel();
        jPanel1Label2 = new javax.swing.JLabel();
        jPanel1Label1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();

        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setBackground(new java.awt.Color(36, 47, 65));

        jLabel1.setFont(new java.awt.Font("Yu Gothic", 1, 48)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 204, 153));
        jLabel1.setText("Login");

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Email");

        jEmailField.setBackground(new java.awt.Color(36, 47, 65));
        jEmailField.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jEmailField.setForeground(new java.awt.Color(204, 204, 204));
        jEmailField.setText("Enter Your Email");
        jEmailField.setToolTipText("");
        jEmailField.setBorder(null);

        jLabel3.setBackground(new java.awt.Color(36, 47, 65));
        jLabel3.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Password");

        jPasswordField.setEditable(false);
        jPasswordField.setBackground(new java.awt.Color(36, 47, 65));
        jPasswordField.setFont(new java.awt.Font("Verdana", 0, 14)); // NOI18N
        jPasswordField.setForeground(new java.awt.Color(204, 204, 204));
        jPasswordField.setText("dsfsdfdsfsdfsdfsf");
        jPasswordField.setBorder(null);

        showPassword.setBackground(new java.awt.Color(36, 47, 65));
        showPassword.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
        showPassword.setForeground(new java.awt.Color(255, 255, 255));
        showPassword.setText("Show Password");
        showPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showPasswordActionPerformed(evt);
            }
        });

        jSignIn.setBackground(new java.awt.Color(255, 102, 102));
        jSignIn.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jSignIn.setForeground(new java.awt.Color(255, 255, 255));
        jSignIn.setText("Sign In");
        jSignIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jSignInActionPerformed(evt);
            }
        });

        jRegister.setBackground(new java.awt.Color(255, 102, 102));
        jRegister.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jRegister.setForeground(new java.awt.Color(255, 255, 255));
        jRegister.setText("Register");
        jRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRegisterActionPerformed(evt);
            }
        });

        jButton3.setBackground(new java.awt.Color(0, 204, 204));
        jButton3.setText("Forgot Password");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(172, 172, 172)
                        .addComponent(jLabel1))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel3)
                                .addComponent(jLabel2)
                                .addComponent(jEmailField)
                                .addComponent(jSeparator1)
                                .addComponent(jPasswordField)
                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jSignIn, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(63, 63, 63)
                                        .addComponent(jRegister))))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGap(114, 114, 114)
                                .addComponent(showPassword)
                                .addGap(117, 117, 117)))))
                .addContainerGap(79, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButton3)
                .addGap(183, 183, 183))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(94, 94, 94)
                .addComponent(jLabel1)
                .addGap(55, 55, 55)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jEmailField, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(showPassword)
                .addGap(63, 63, 63)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRegister)
                    .addComponent(jSignIn))
                .addGap(18, 18, 18)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton3)
                .addContainerGap(64, Short.MAX_VALUE))
        );

        add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 0, 500, 670));

        jPanel1.setBackground(new java.awt.Color(255, 153, 153));
        jPanel1.setLayout(null);

        jPanel1Label3.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jPanel1Label3.setForeground(new java.awt.Color(255, 204, 51));
        jPanel1Label3.setText("Chase Your Dream");
        jPanel1Label3.setToolTipText("");
        jPanel1.add(jPanel1Label3);
        jPanel1Label3.setBounds(160, 530, 200, 60);

        jPanel1Label2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1Label2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Roy\\Documents\\NetBeansProjects\\login_form_1\\roy-hill.png")); // NOI18N
        jPanel1.add(jPanel1Label2);
        jPanel1Label2.setBounds(90, 200, 300, 260);

        jPanel1Label1.setFont(new java.awt.Font("Monotype Corsiva", 1, 48)); // NOI18N
        jPanel1Label1.setForeground(new java.awt.Color(255, 153, 153));
        jPanel1Label1.setText("Login Panel 1");
        jPanel1.add(jPanel1Label1);
        jPanel1Label1.setBounds(120, 120, 300, 50);

        jLabel4.setIcon(new javax.swing.ImageIcon("C:\\Users\\Roy\\Documents\\NetBeansProjects\\login_form_1\\Spiral.png")); // NOI18N
        jLabel4.setText("jLabel4");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(260, 0, 310, 670);

        jLabel8.setIcon(new javax.swing.ImageIcon("C:\\Users\\Roy\\Documents\\NetBeansProjects\\login_form_1\\Mac01.jpg")); // NOI18N
        jPanel1.add(jLabel8);
        jLabel8.setBounds(0, 0, 530, 670);

        add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 530, 670));
    }// </editor-fold>                        
    //Show or Hide Password Operation:
    private void showPasswordActionPerformed(java.awt.event.ActionEvent evt) {                                             

        if(showPassword.isSelected()){
            jPasswordField.setEchoChar((char)0);
        }else{
          jPasswordField.setEchoChar('*');
        }
    }                                            

    private void jRegisterActionPerformed(java.awt.event.ActionEvent evt) {                                          

    }                                         


    private void jSignInActionPerformed(java.awt.event.ActionEvent evt) {                                        

    }                                       


    public static void main(String [] args){
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new loginPanel().setVisible(true);
            }
        });
    }

    private void jSignInActionPerformed(java.awt.event.ActionEvent evt) {                                              

        }
    }

    private javax.swing.JButton jButton3;
    private javax.swing.JTextField jEmailField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel jPanel1Label1;
    private javax.swing.JLabel jPanel1Label2;
    private javax.swing.JLabel jPanel1Label3;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPasswordField jPasswordField;
    private javax.swing.JButton jRegister;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JButton jSignIn;
    private javax.swing.JCheckBox showPassword;
    // End of variables declaration                   
}
0
Roy 20 avril 2017 à 08:18

3 réponses

Meilleure réponse

Oui. Enfin fait avec ce problème. (J'ai essayé de nombreuses façons)

Je viens de remplacer cette ligne:

La classe publique loginPanel étend javax.swing.JPanel

Avec ça:

La classe publique loginPanel étend javax.swing.JFrame

0
Roy 21 avril 2017 à 05:11

Tous les composants doivent être, éventuellement, ajoutés à un conteneur de niveau supérieur (c'est-à-dire un JFrame) avant de pouvoir être affichés à l'écran

Jetez un œil à Comment créer des cadres (Windows principal) pour plus de détails

1
MadProgrammer 20 avril 2017 à 05:28

Dans la classe principale, vous devez appeler votre cadre.

public static void main(String[] args) {       
        new loginpanel().setVisible(true);
    }
-1
Dani 20 avril 2017 à 06:19