我在NetBeans中创建了登录面板(你知道拖放)。我将代码复制到Exlipse(因为我工作),我很震惊。代码无法正常工作。我只看到框架和标签信息(甚至不只是一个)。 NetBeans中的代码是否可以在Eclipse中运行?
这是我的代码:
package javaapplication40;
public class NewJPanel extends javax.swing.JPanel {
public NewJPanel() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
LoginLabel = new javax.swing.JLabel();
HasloLabel = new javax.swing.JLabel();
MscHasla = new javax.swing.JPasswordField();
MscLoginu = new javax.swing.JTextField();
ZalogujButton = new javax.swing.JButton();
LoginLabel.setText("Login");
HasloLabel.setText("Haslo");
MscHasla.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MscHaslaActionPerformed(evt);
}
});
ZalogujButton.setText("Zaloguj");
ZalogujButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ZalogujButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ZalogujButton)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(HasloLabel)
.addComponent(LoginLabel))
.addGap(63, 63, 63)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(MscHasla)
.addComponent(MscLoginu, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE))))
.addContainerGap(144, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(LoginLabel)
.addComponent(MscLoginu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(HasloLabel)
.addComponent(MscHasla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(ZalogujButton)
.addContainerGap(143, Short.MAX_VALUE))
);
}// </editor-fold>
private void MscHaslaActionPerformed(java.awt.event.ActionEvent evt) {
}
private void ZalogujButtonActionPerformed(java.awt.event.ActionEvent evt) {
if( MscLoginu.getText().equals("Admin")&& MscHasla.getText().equals("1234") ){
new GlowneOkno().setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JLabel HasloLabel;
private javax.swing.JLabel LoginLabel;
private javax.swing.JPasswordField MscHasla;
private javax.swing.JTextField MscLoginu;
private javax.swing.JButton ZalogujButton;
// End of variables declaration
}