ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
322
322
EMPFEHLEN
-
Hallo,
ich habe 2 Fenster programmiert. Das erste Fenster hat einen Start-Button, mit dem man das zweite Fenster öffnen kann. Wenn man dann das zweite Fenster schließt, dann schließen beide Fenster. Ich möchte aber das zweite Fenster schließen, ohne dass das erste Fenster dabei geschlossen wird.
Fenster 1:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
public class NewJFrame extends javax.swing.JFrame { /** Creates new form NewJFrame */ 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("START"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(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() .addContainerGap() .addComponent(jButton1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame1().setVisible(true); } }); }//GEN-LAST:event_jButton1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; // End of variables declaration//GEN-END:variables }
Fenster 2:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
public class NewJFrame1 extends javax.swing.JFrame { /** Creates new form NewJFrame1 */ public NewJFrame1() { 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables }
danke
gruss
-
23.05.08 13:47 #2
Versuch mal ob es klappte, wenn du die Zeile
aus dem Code des 2. Fensters rausnimmst.Code java:1
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
"... Jeder von uns ist Kunst... gezeichnet vom Leben" (Casper)
"Sir?, we're sorrounded!"
"Excellent, we can attack in any direction"
Ähnliche Themen
-
fenster schließen
Von Steffilove im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 8Letzter Beitrag: 30.03.07, 12:51 -
[c++] Fenster schließen
Von haribald im Forum C/C++Antworten: 3Letzter Beitrag: 12.10.06, 09:04 -
Fenster schließen
Von Tunemaster im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 7Letzter Beitrag: 21.06.05, 12:03 -
Link in altem Fenster öffnen + Fenster schließen
Von PhoenixDH im Forum Javascript & AjaxAntworten: 17Letzter Beitrag: 08.09.04, 22:10 -
Fenster öffnen, Inhalt drucken, Fenster schließen
Von dermac'z im Forum Javascript & AjaxAntworten: 8Letzter Beitrag: 02.07.04, 15:44





Zitieren
Login





