public class FrameA extends JFrame { private FrameB frameB; public FrameA(FrameB frameB){ this.frameB=frameB; } public void methode(){ frameB.methodeB(); } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic class FormANaiss1 extends javax.swing.JFrame { private FormChoixRegistre1 formChoixReg;//intanciation de formulaire A dans B /** Creates new form FormANaiss */ public FormANaiss1(FormChoixRegistre1 frm) { this.formChoixReg=frm; // Modification du mon code initial par la methode renvoyant les lignes de A // for(int i=0;i<formChoixReg.listeRegistreCharger().size();i++){ // cmbCodeRegistre.addItem(formChoixReg.listeRegistreCharger().get(i)); methodeListe(); } initComponents(); setSize(807, 645); setLocationRelativeTo(null); } }
public void methodeListe(){ formChoixReg.listeRegistreCharger(); }
public ArrayList listeRegistreCharger(){ int size = bModel.getRowCount(); ArrayList totalRegistreCharger=new ArrayList(); for ( int i = 0; i < size; i++ ) { totalRegistreCharger.add(bModel.getValueAt(i, 0)); } return totalRegistreCharger; }mais toujours rien,je veux pourtant arriver à comprendre ceci,j'en rencontrerai plein d'implentation du genre dans le reste de mon application,un concept essentiel qu'il me faut capter.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * FormChoixRegistre.java * * Created on 27 juin 2011, 10:34:03 */ package com.anso.dpicol.vue; import com.anso.dpicol.dao.DataBaseConnector; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import com.mysql.jdbc.ResultSetMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; /** * * @author Cool */ public final class FormChoixRegistre1 extends javax.swing.JFrame { private FormANaiss1 formNaiss; //creation d'une reference de FormANaiss1 private ArrayList listDesRegistres; private String ValTxtCodeRegistre; private int colNo; private Object objects[]; /** Creates new form FormChoixRegistre */ public FormChoixRegistre1(FormANaiss1 fan) { //constructeur avec comme parameter FormANaiss1 this.formNaiss=fan; initComponents(); setResizable(false); setLocationRelativeTo(null); listeRegistre(); TxtNbRegistreDispo.setText(Integer.toString(aModel.getRowCount())); } public boolean verif(Object[] val){ boolean result=true; for(int k=0;k< txtJtableRegCharger.getModel().getRowCount();k++){ if(txtJtableRegCharger.getModel().getValueAt(k, 0) == val){ JOptionPane.showMessageDialog(null, val+" existe déjà", "Erreur", JOptionPane.ERROR_MESSAGE); result=false; } } return result; } public void listeRegistre() { try { // String Query = "SELECT * FROM registres "; String Query = "SELECT * FROM registres "; Connection connection = (Connection) DataBaseConnector.getConnection(); PreparedStatement ps = (PreparedStatement) connection.prepareStatement(Query); ResultSet rs = ps.executeQuery(); ResultSetMetaData md = (ResultSetMetaData) rs.getMetaData(); colNo = md.getColumnCount(); while (rs.next()) { objects = new Object[colNo]; for (int i = 0; i < colNo; i++) { objects[i] = rs.getObject(i+1); } aModel.addRow(objects); } txtJtableRegDispo.repaint(); } catch (SQLException ex) { Logger.getLogger(FormChoixRegistre1.class.getName()).log(Level.SEVERE, null, ex); } } /** 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() { PanContenu = new javax.swing.JPanel(); PanEntete = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); PanCentral = new javax.swing.JPanel(); PanRegistreTotal = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); TxtNbRegistreDispo = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); listDesRegistres=new ArrayList(); txtJtableRegDispo = new javax.swing.JTable(); PanCmd = new javax.swing.JPanel(); CmdAjouter = new javax.swing.JButton(); CmdRetirer = new javax.swing.JButton(); CmdQuitter = new javax.swing.JButton(); PanRegistreSelectionne = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); txtNbRegCharger = new javax.swing.JTextField(); jScrollPane2 = new javax.swing.JScrollPane(); listeDesRegCharger=new ArrayList(); txtJtableRegCharger = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle("Etat Civil"); PanContenu.setBackground(new java.awt.Color(102, 102, 102)); PanContenu.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); PanContenu.setLayout(new java.awt.BorderLayout()); PanEntete.setBackground(new java.awt.Color(0, 0, 0)); PanEntete.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); PanEntete.setForeground(new java.awt.Color(255, 153, 0)); jLabel1.setFont(new java.awt.Font("Perpetua", 3, 24)); jLabel1.setForeground(new java.awt.Color(255, 153, 0)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("REGISTRES D'ACTES DE NAISSANCE A CHARGER"); javax.swing.GroupLayout PanEnteteLayout = new javax.swing.GroupLayout(PanEntete); PanEntete.setLayout(PanEnteteLayout); PanEnteteLayout.setHorizontalGroup( PanEnteteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE) ); PanEnteteLayout.setVerticalGroup( PanEnteteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE) ); PanContenu.add(PanEntete, java.awt.BorderLayout.NORTH); PanCentral.setLayout(new java.awt.BorderLayout()); PanRegistreTotal.setBackground(new java.awt.Color(102, 102, 102)); PanRegistreTotal.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), "Tous Les Registres", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Perpetua", 3, 18), new java.awt.Color(0, 0, 204))); // NOI18N jLabel2.setFont(new java.awt.Font("Perpetua", 3, 18)); jLabel2.setForeground(new java.awt.Color(0, 204, 0)); jLabel2.setText("Nombre De Registres :"); TxtNbRegistreDispo.setBackground(new java.awt.Color(255, 204, 153)); TxtNbRegistreDispo.setFont(new java.awt.Font("Perpetua", 3, 20)); // NOI18N TxtNbRegistreDispo.setForeground(new java.awt.Color(0, 204, 51)); TxtNbRegistreDispo.setHorizontalAlignment(javax.swing.JTextField.CENTER); TxtNbRegistreDispo.setBorder(null); TxtNbRegistreDispo.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { TxtNbRegistreDispoMouseClicked(evt); } }); TxtNbRegistreDispo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TxtNbRegistreDispoActionPerformed(evt); } }); String[] tableColumnsName = {"Liste des registres disponibles"}; aModel = new DefaultTableModel() { public boolean isCellEditable(int row, int col) { return false; } }; txtJtableRegDispo.getSelectionModel().addListSelectionListener(new RowListener()); aModel.setColumnIdentifiers(tableColumnsName); txtJtableRegDispo.setModel(aModel); txtJtableRegDispo.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { txtJtableRegDispoMouseClicked(evt); } }); txtJtableRegDispo.addInputMethodListener(new java.awt.event.InputMethodListener() { public void caretPositionChanged(java.awt.event.InputMethodEvent evt) { txtJtableRegDispoCaretPositionChanged(evt); } public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) { } }); jScrollPane1.setViewportView(txtJtableRegDispo); javax.swing.GroupLayout PanRegistreTotalLayout = new javax.swing.GroupLayout(PanRegistreTotal); PanRegistreTotal.setLayout(PanRegistreTotalLayout); PanRegistreTotalLayout.setHorizontalGroup( PanRegistreTotalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanRegistreTotalLayout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(TxtNbRegistreDispo, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE) ); PanRegistreTotalLayout.setVerticalGroup( PanRegistreTotalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanRegistreTotalLayout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE) .addGroup(PanRegistreTotalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(TxtNbRegistreDispo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) ); PanCentral.add(PanRegistreTotal, java.awt.BorderLayout.WEST); PanCmd.setBackground(new java.awt.Color(102, 102, 102)); PanCmd.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); CmdAjouter.setFont(new java.awt.Font("Perpetua", 3, 18)); // NOI18N CmdAjouter.setText(" Ajouter "); CmdAjouter.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); CmdAjouter.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CmdAjouterActionPerformed(evt); } }); CmdRetirer.setFont(new java.awt.Font("Perpetua", 3, 18)); // NOI18N CmdRetirer.setText(" Retirer "); CmdRetirer.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); CmdRetirer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CmdRetirerActionPerformed(evt); } }); CmdQuitter.setFont(new java.awt.Font("Perpetua", 3, 18)); CmdQuitter.setText(" Quitter "); CmdQuitter.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); CmdQuitter.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CmdQuitterActionPerformed(evt); } }); javax.swing.GroupLayout PanCmdLayout = new javax.swing.GroupLayout(PanCmd); PanCmd.setLayout(PanCmdLayout); PanCmdLayout.setHorizontalGroup( PanCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(CmdAjouter, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) .addComponent(CmdRetirer, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) .addComponent(CmdQuitter, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) ); PanCmdLayout.setVerticalGroup( PanCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PanCmdLayout.createSequentialGroup() .addContainerGap() .addComponent(CmdAjouter) .addGap(18, 18, 18) .addComponent(CmdRetirer) .addGap(43, 43, 43) .addComponent(CmdQuitter) .addContainerGap(32, Short.MAX_VALUE)) ); PanCentral.add(PanCmd, java.awt.BorderLayout.CENTER); PanRegistreSelectionne.setBackground(new java.awt.Color(102, 102, 102)); PanRegistreSelectionne.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), "Registres Sélectionnés", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Perpetua", 3, 18), new java.awt.Color(0, 0, 204))); // NOI18N jLabel3.setFont(new java.awt.Font("Perpetua", 3, 18)); jLabel3.setForeground(new java.awt.Color(255, 0, 0)); jLabel3.setText("Nombres De registres :"); txtNbRegCharger.setBackground(new java.awt.Color(255, 204, 153)); txtNbRegCharger.setFont(new java.awt.Font("Perpetua", 3, 20)); // NOI18N txtNbRegCharger.setForeground(new java.awt.Color(255, 0, 0)); txtNbRegCharger.setHorizontalAlignment(javax.swing.JTextField.CENTER); txtNbRegCharger.setBorder(null); String[] tableColumnsName1 = {"Liste des registres àcharger"}; bModel = new DefaultTableModel() { public boolean isCellEditable(int row, int col) { return false; } }; txtJtableRegCharger.getSelectionModel().addListSelectionListener(new RowListener1()); bModel.setColumnIdentifiers(tableColumnsName1); txtJtableRegCharger.setModel(bModel); txtJtableRegCharger.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { txtJtableRegChargerMouseClicked(evt); } }); txtJtableRegCharger.addInputMethodListener(new java.awt.event.InputMethodListener() { public void caretPositionChanged(java.awt.event.InputMethodEvent evt) { txtJtableRegChargerCaretPositionChanged(evt); } public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) { } }); jScrollPane2.setViewportView(txtJtableRegCharger); javax.swing.GroupLayout PanRegistreSelectionneLayout = new javax.swing.GroupLayout(PanRegistreSelectionne); PanRegistreSelectionne.setLayout(PanRegistreSelectionneLayout); PanRegistreSelectionneLayout.setHorizontalGroup( PanRegistreSelectionneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE) .addGroup(PanRegistreSelectionneLayout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtNbRegCharger, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)) ); PanRegistreSelectionneLayout.setVerticalGroup( PanRegistreSelectionneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PanRegistreSelectionneLayout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE) .addGroup(PanRegistreSelectionneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(txtNbRegCharger, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) ); PanCentral.add(PanRegistreSelectionne, java.awt.BorderLayout.EAST); PanContenu.add(PanCentral, java.awt.BorderLayout.CENTER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(PanContenu, javax.swing.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(PanContenu, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// </editor-fold> private void CmdRetirerActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int a=txtJtableRegCharger.getSelectedRow(); int[] selection = txtJtableRegCharger.getSelectedRows(); for(int i = selection.length - 1; i >= 0; i--){ bModel.removeRow(selection[i]); txtNbRegCharger.setText(Integer.toString(bModel.getRowCount())); } } private void CmdQuitterActionPerformed(java.awt.event.ActionEvent evt) { final int[] rep = new int[1]; rep[0] = JOptionPane.showConfirmDialog(null, "Voulez-vous vraiment quitter cette fenêtre?", "Quitter", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (rep[0] == JOptionPane.YES_OPTION) //System.exit(6); { for(int k=0;k<getListeRegistreCharger().size();k++){ //tentative de remplir le combo a travers la method getListeRegistreCharger() this.formNaiss.setRegistres(getListeRegistreCharger().get(k)); } this.setVisible(false); } } private void txtJtableRegDispoMouseClicked(java.awt.event.MouseEvent evt) { } private void CmdAjouterActionPerformed(java.awt.event.ActionEvent evt) { int i=txtJtableRegDispo.getSelectedRow(); //int k=; String c=(String) txtJtableRegDispo.getValueAt(i, 0); Object [] valeur = {txtJtableRegDispo.getValueAt(i, 0)}; txtJtableRegDispo.clearSelection(); if ( isValueValide( valeur ) ){ bModel.addRow(valeur); txtNbRegCharger.setText(Integer.toString(bModel.getRowCount())); } else {JOptionPane.showMessageDialog(null, c+" existe déjà", "Erreur", JOptionPane.ERROR_MESSAGE); System.out.println("la valeur du doublon est :"+valeur); } } private void txtJtableRegChargerMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: } private void txtJtableRegChargerCaretPositionChanged(java.awt.event.InputMethodEvent evt) { // TODO add your handling code here: } private void TxtNbRegistreDispoActionPerformed(java.awt.event.ActionEvent evt) { } private void txtJtableRegDispoCaretPositionChanged(java.awt.event.InputMethodEvent evt) { // TODO add your handling code here: } private void TxtNbRegistreDispoMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: if(evt.getClickCount()==2) System.out.println("\n"+listeRegistreCharger()); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { FormANaiss1 fan=new FormANaiss1(); new FormChoixRegistre1(fan).setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton CmdAjouter; private javax.swing.JButton CmdQuitter; private javax.swing.JButton CmdRetirer; private javax.swing.JPanel PanCentral; private javax.swing.JPanel PanCmd; private javax.swing.JPanel PanContenu; private javax.swing.JPanel PanEntete; private javax.swing.JPanel PanRegistreSelectionne; private javax.swing.JPanel PanRegistreTotal; private javax.swing.JTextField TxtNbRegistreDispo; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTable txtJtableRegCharger; private ArrayList listeDesRegCharger; private javax.swing.JTable txtJtableRegDispo; private DefaultTableModel aModel,bModel; private javax.swing.JTextField txtNbRegCharger; // End of variables declaration private class RowListener implements ListSelectionListener { @Override public void valueChanged(ListSelectionEvent event) { // if (!"Enregistrer le registre".equals(CmdNouveauRegistre.getText().trim())) { for (int i = 0; i < txtJtableRegDispo.getRowCount(); i++) { if (txtJtableRegDispo.getSelectedRow() == i) { CmdAjouter.setEnabled(true); CmdRetirer.setEnabled(false); txtJtableRegCharger.clearSelection(); } } } } private class RowListener1 implements ListSelectionListener { @Override public void valueChanged(ListSelectionEvent event) { for (int k = 0; k < txtJtableRegCharger.getRowCount(); k++) { if (txtJtableRegCharger.getSelectedRow() == k) { CmdAjouter.setEnabled(false); CmdRetirer.setEnabled(true); txtJtableRegDispo.clearSelection(); } } } } public Object getValeur() { Object val = ""; for (int i = 0; i < txtJtableRegDispo.getRowCount(); i++) { if (txtJtableRegDispo.getSelectedRow() == i) { val = txtJtableRegDispo.getModel().getValueAt(i, 0); } } return val; } public int getRowCount() { return this.txtJtableRegCharger.getModel().getRowCount(); } public Map getLookAndFeelsMap(){ UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); Map map = new TreeMap(); for(int i=0; i<info.length;i++){ String nomLF = info[i].getName(); String nomClasse = info[i].getClassName(); map.put(nomLF,nomClasse); } return map; } public boolean isValueValide( Object[] value ) { int size = bModel.getRowCount(); for ( int i = 0; i < size; i++ ) { if ( value[0].equals( bModel.getValueAt(i, 0) ) ) return false; } return true; } public ArrayList listeRegistreCharger(){ int size = bModel.getRowCount(); ArrayList totalRegistreCharger=new ArrayList(); for ( int i = 0; i < size; i++ ) { totalRegistreCharger.add(bModel.getValueAt(i, 0)); } return totalRegistreCharger; } public ArrayList getListeRegistreCharger(){ int size = bModel.getRowCount(); ArrayList totalRegistreCharger=new ArrayList(); for ( int i = 0; i < size; i++ ) { totalRegistreCharger.add(bModel.getValueAt(i, 0)); } return totalRegistreCharger; } }
package com.anso.dpicol.vue; import com.anso.dpicol.vue.FormChoixRegistre1; import javax.swing.JOptionPane; import javax.swing.SwingConstants; /** * * @author Cool */ public final class FormANaiss1 extends javax.swing.JFrame { private javax.swing.JComboBox CmbCodeRegistre; /** Creates new form FormANaiss */ public FormANaiss1() { FormChoixRegistre1 formChoixReg=new FormChoixRegistre1(this); initComponents(); setSize(807, 645); setLocationRelativeTo(null); } private void initComponents() { CmbCodeRegistre = new javax.swing.JComboBox(); } public void setRegistres(Object reg) {//setter de remplisage du combobox this.CmbCodeRegistre.addItem(reg); } }
this.formNaiss.setRegistres(getListeRegistreCharger().get(k));" ne marche pas, puisque mon combo reste vide.par contre,etant dans mon formulaire je constate que quand je fais "
System.out.println(getListeRegistreCharger().get(k));" que getListeRegistreCharger() contient les données.Est ce la methode setRegistres()de FormANaiss1 qui ne marche pas? la voici:
public void setRegistres(Object reg) {/*je me disais qu'en lui fournissant comme parametre la valeur à l'indice k de getListeRegistreCharger() depuis FormChoixRegistre1 ça aurait marcher,mais c'est pas le cas */ this.CmbCodeRegistre.addItem(reg); }
public void setRegistre(DefaultTableModel dtf) {//setter de remplisage du combobox this.CmbCodeRegistre.addItem(dtf); }
private void CmdQuitterActionPerformed(java.awt.event.ActionEvent evt) { final int[] rep = new int[1]; rep[0] = JOptionPane.showConfirmDialog(null, "Voulez-vous vraiment quitter cette fenêtre?", "Quitter", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (rep[0] == JOptionPane.YES_OPTION) //System.exit(6); { for(int k=0;k<getListeRegistreCharger().size();k++){ //tentative de remplir le combo a travers la method getListeRegistreCharger() this.formNaiss.setRegistres(getListeRegistreCharger().ge(k)); System.out.println(getListeRegistreCharger().get(k)); } this.setVisible(false); } }
private void CmdQuitterActionPerformed(java.awt.event.ActionEvent evt) { final int[] rep = new int[1]; rep[0] = JOptionPane.showConfirmDialog(null, "Voulez-vous vraiment quitter cette fenêtre?", "Quitter", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (rep[0] == JOptionPane.YES_OPTION) //System.exit(6); { formNaiss.setRegistre(this.getDefault()); this.setVisible(false);//fermé la ferme en cours.ou si on veut System.exit(6); } }
public DefaultTableModel getDefault(){ return bModel; }
public void setRegistre(DefaultTableModel dtf) {//setter de remplisage du combobox this.CmbCodeRegistre.addItem(dtf); }pourrais-je l'utilisé dans le constructeur de ma frame afin d'avoir le combo rempli au demarrage de la fenetre?
public void setRegistres(Object reg) { this.CmbCodeRegistre.addItem(reg); }marche bien,avec quel parametre dois-je l'appeler dans le contructeur afin de remplir le combo?
import java.util.ArrayList; /** * FrmA.java * * @author GonConan * Created on 17 nov. 2011, 18:20:20 */ public class FrmA extends javax.swing.JFrame { FrmB frmB = null; public FrmA( FrmB frm ) { this(); frmB = frm; } /** Creates new form FrmA */ public FrmA() { 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() { jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {"1", "a", "ab", "GodConan"}, {"2", "b", "cd", "GodConan"}, {"3", "c", "ef", "GodConan"}, {"4", "d", "gh", "GodConan"} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE) ); jButton1.setText("Action"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addContainerGap(337, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addContainerGap(27, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { if ( frmB != null ) { ArrayList list = new ArrayList(); int row = jTable1.getModel().getRowCount(); System.out.println("row : " + row); for ( int i = 0; i < row; i++ ) { Object obj = jTable1.getModel().getValueAt(i, 2); list.add(obj); } frmB.setList(list); frmB.setVisible(true); } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { FrmB frm = new FrmB(); new FrmA(frm).setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration }
import java.util.ArrayList; import javax.swing.DefaultComboBoxModel; /** * FrmB.java * * @author Godconan * Created on 17 nov. 2011, 18:25:00 */ public class FrmB extends javax.swing.JFrame { /** Creates new form FrmB */ public FrmB() { initComponents(); } public void setList( ArrayList list ) { ((DefaultComboBoxModel)jComboBox1.getModel()).removeAllElements(); for ( Object obj : list) { ((DefaultComboBoxModel)jComboBox1.getModel()).addElement(obj); } } /** 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() { jPanel1 = new javax.swing.JPanel(); jComboBox1 = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(258, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(211, Short.MAX_VALUE)) ); jButton1.setText("Ok"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jButton1) .addContainerGap(355, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(11, Short.MAX_VALUE) .addComponent(jButton1) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FrmB().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; // End of variables declaration }
import javax.swing.table.DefaultTableModel; /** * FrmA.java * * Created on 17 nov. 2011, 18:20:20 * @author GodConan */ public class FrmA extends javax.swing.JFrame { FrmB frmB = null; ModelOfMyData dataModel = null; public FrmA( ModelOfMyData data, FrmB frm ) { this(); dataModel = data; frmB = frm; // bien obligé pour la rendre visible ;o) // ici il faudrai plutot faire un getTableModel et construire le model dans ModelOfMyData // mais javai pas envi de refaire le code ;o) dataModel.setTableModel( (DefaultTableModel) jTable1.getModel() ); } /** Creates new form FrmA */ public FrmA() { 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() { jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {"1", "a", "ab", "GodConan"}, {"2", "b", "cd", "GodConan"}, {"3", "c", "ef", "GodConan"}, {"4", "d", "gh", "GodConan"} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE) ); jButton1.setText("Action"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addContainerGap(337, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addContainerGap(27, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { dataModel.fireDataForCombo(); frmB.setVisible(true); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ModelOfMyData data = new ModelOfMyData(); FrmB frm = new FrmB( data ); new FrmA(data, frm).setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration }
import java.util.ArrayList; import javax.swing.DefaultComboBoxModel; /* */ /** * FrmB.java * * Created on 17 nov. 2011, 18:25:00 * @author GodConan */ public class FrmB extends javax.swing.JFrame { /** Creates new form FrmB */ public FrmB(ModelOfMyData model) { initComponents(); jComboBox1.setModel(model.getComboModel()); } public FrmB() { 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() { jPanel1 = new javax.swing.JPanel(); jComboBox1 = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(258, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(211, Short.MAX_VALUE)) ); jButton1.setText("Ok"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jButton1) .addContainerGap(355, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(11, Short.MAX_VALUE) .addComponent(jButton1) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { this.setVisible(false); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; // End of variables declaration }
import javax.swing.DefaultComboBoxModel; import javax.swing.table.DefaultTableModel; /** * * @author GodConan */ public class ModelOfMyData { DefaultTableModel tModel = null; DefaultComboBoxModel cModel = null; public ModelOfMyData() { } public void setTableModel( DefaultTableModel model ) { tModel = model; } // je fais au plus simple ;o) dans l ideal il faudrai un mecanisme de datalistener public void fireDataForCombo() { try { int row = tModel.getRowCount(); getComboModel().removeAllElements(); for ( int i = 0; i < row; i++ ) { Object obj = tModel.getValueAt(i, 2); getComboModel().addElement(obj); } } catch ( Exception e ) { System.out.println("Erreur :" + e); } } // ici on devrai faire aussi une methode get TableModel pour la jtable ;o) mais chui faineant ;o) public DefaultComboBoxModel getComboModel() { if ( cModel null ) cModel new DefaultComboBoxModel(); return cModel; } }
(System.exit(6); )derriere le bouton quitter de mon formulaire A,les données ne sont plus transférées dans le combobox du formulaire
(fanModif), par contre si je gardes ce code
:( this.setVisible(false); )les données se chargent dans le combo? Est ce pour dire que :
(System.exit(6); )détruit le formulaire avec toutes ces données temporaires'et si c'est le cas,comment puis-je quitter le formulaire A tout en conservant toujours les données afin de charger le combobox de B bien ulterieurement à l'ouverture de celui ci?
private void CmdQuitterActionPerformed(java.awt.event.ActionEvent evt) { final int[] rep = new int[1]; rep[0] = JOptionPane.showConfirmDialog(null, "Voulez-vous vraiment quitter cette fenêtre?", "Quitter", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (rep[0] == JOptionPane.YES_OPTION) //System.exit(6); { dataModel.fireDataForCombo(); fanModif.setVisible(true); //System.exit(6); this.setVisible(false); } }