Ich möchte gerne ein TextField in NetBeans erstellen, in der Designer Form wird dies auch gemacht. Sobald ich den Debugging Modus anstelle, kann in die TextBox nicht reingeschrieben werden. Wo könnte das Problem liegen ? Es werden auch keine errors oder warns ausgegeben
Textfield Hilfe in Java
- robbi2304
- Geschlossen
- Erledigt
-
-
Wenn du uns deinen Code zeigen würdest..wie du das TextField einbindest...dann könnte man dir helfen
-
-
Wenn du wüsstest wie das ganze in NetBeans funktioniert
Ehm...Eventuell mal einen Doppelklick darauf machen..oder schauen?
Also in NetBeans..kann man durchaus auch nur Code schreiben
-
Ich sende einfach mal den kompletten Code. Vielleicht ist da wirklich einfach ein Fehler.
Java
Alles anzeigenpackage Secure; import java.awt.HeadlessException; import java.sql.*; import javax.swing.*; public class NewJFrame extends javax.swing.JFrame { Connection conn=null; PreparedStatement pst=null; ResultSet rs=null; public NewJFrame() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel7 = new javax.swing.JLabel(); jButton19 = new javax.swing.JButton(); txtusername = new javax.swing.JTextField(); txtpassword = new javax.swing.JTextField(); jLabel7.setIcon(new javax.swing.ImageIcon("C:\\Users\\Hauptrechner\\Desktop\\datwe\\DRB\\Hintergrund_1.jpg")); // NOI18N jLabel7.setText("jLabel7"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setAlwaysOnTop(true); setBackground(new java.awt.Color(255, 102, 153)); setFocusableWindowState(false); setFont(new java.awt.Font("Adobe Fan Heiti Std B", 0, 10)); // NOI18N setForeground(new java.awt.Color(255, 102, 102)); setLocation(new java.awt.Point(800, 600)); setLocationByPlatform(true); setMaximizedBounds(new java.awt.Rectangle(0, 0, 800, 600)); setMinimumSize(new java.awt.Dimension(800, 600)); setSize(new java.awt.Dimension(800, 600)); jButton19.setText("Anmelden"); jButton19.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton19ActionPerformed(evt); } }); txtusername.setText("jTextField1"); txtusername.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtusernameActionPerformed(evt); } }); txtpassword.setText("jTextField1"); txtpassword.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtpasswordKeyPressed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(68, 68, 68) .addComponent(jButton19) .addContainerGap(653, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtusername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(350, 350, 350)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(85, 85, 85) .addComponent(txtusername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 430, Short.MAX_VALUE) .addComponent(jButton19) .addContainerGap()) ); pack(); }// </editor-fold> private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) { conn =MySqlConnect.ConnectDB(); String Sql="SELECT * FROM login where username=? and password=?"; try{ pst=conn.prepareStatement(Sql); pst.setString(1,txtusername.getText()); pst.setString(2,txtpassword.getText()); rs=pst.executeQuery(); if(rs.next()){ uebersicht w=new uebersicht(); w.setVisible(true); } else{ JOptionPane.showMessageDialog(null,"Falsche Daten.","Access Denied",JOptionPane.ERROR_MESSAGE); } } catch(HeadlessException | SQLException e) { JOptionPane.showMessageDialog(null,e); } } private void txtusernameActionPerformed(java.awt.event.ActionEvent evt) { } private void txtpasswordKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here: } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(() -> { new NewJFrame().setVisible(true); }); } // Variables declaration - do not modify private javax.swing.JButton jButton19; private javax.swing.JLabel jLabel7; private javax.swing.JTextField txtpassword; private javax.swing.JTextField txtusername; // End of variables declaration }
-
setFocusableWindowState(false);
Hier das in Zeile 33 auf true setzen
-
Ohja, und entschuldige meinen vorletzten Thread.
-
breadfish.de
Hat das Thema geschlossen.