IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Applets Java Discussion :

Comment recuperer valeur Jcheckbox


Sujet :

Applets Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Août 2008
    Messages
    35
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 35
    Par défaut Comment recuperer valeur Jcheckbox
    Bonjour

    Je dois rendre un projet mais la je suis bloqué voici ma classe
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.io.*;
    import java.text.DateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
     
    public class Fenetre extends Applet implements ActionListener
     
    {
    	JPanel panelg, paneln, panel1, panel2, panel3, panel4, pan3;
    	JButton brap, brnb, bsalsa, bjazz, bajouter, bnext, bfirst, blast,
    			bprevious, binsert, bprecedent, bdelete;
    	AudioClip fond;
    	JLabel imagerap1, imagerap2, imagerap3, imagerap4;
    	JLabel label1, label2, label3, label4, ajouter, labelvide, labelvide2,
    			labelvide3, ltitre, image, image2, image3, image4, image5, image6;
    	JCheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7;
    	JTextField tf1, tf2, tf3, tf4, tf5, tf6, tf7;
    	DateFormat df;
    	Date date1;
    	JLabel affDateTx;
    	Connection con;
    	Statement stat;
    	ResultSet rs;
    	ArrayList<String> lDonnees;
    	boolean etat;
    	String txt1 =null;
     
    	public void init() {
     
    		this.setLayout(new BorderLayout());
    		this.setBackground(Color.YELLOW);
    		fond=getAudioClip(getCodeBase(),"ton.mp3");
     
    		panel1 = new JPanel();
     
    		panel1.setLayout(new GridLayout(8, 2, 10, 30));
    		panel1.setBackground(Color.YELLOW);
    		panel1.isMaximumSizeSet();
    		paneln = new JPanel(new FlowLayout());
    		paneln.setBackground(Color.YELLOW);
     
    		panel2 = new JPanel();
    		panel2.setLayout(new GridLayout(1, 5));
    		panel2.setBackground(Color.YELLOW);
    		bajouter = new JButton("Ajouter au panier");
    		bajouter.setBackground(Color.YELLOW);
    		bajouter.addActionListener(this);
    		ajouter = new JLabel("                         ");
    		bprecedent = new JButton("Precedent");
    		bprecedent.setBackground(Color.BLACK);
    		bprecedent.setForeground(Color.yellow);
    		bprecedent.addActionListener(this);
     
    		labelvide = new JLabel("                      ");
    		labelvide2 = new JLabel("                      ");
    		labelvide3 = new JLabel("                      ");
    		df = DateFormat.getDateInstance();
    		date1 = new Date();
    		affDateTx = new JLabel(df.format(date1));
    		panel2.add(affDateTx);
     
    		panel2.add(labelvide);
    		panel2.add(labelvide2);
    		panel2.add(labelvide3);
    		panel2.add(ajouter);
    		panel2.add(bajouter);
    		panel2.add(bprecedent);
     
    		label1 = new JLabel("BIENVENU SUR MUSIC ON WEB");
    		Font policeLabel = new Font("Castellar", Font.BOLD, 45);
    		label1.setFont(policeLabel);
    		label1.setForeground(Color.blue);
    		// initialisation des images
    		image = new JLabel(new ImageIcon("logo.JPG"));
    		image2 = new JLabel(new ImageIcon("Chariot.JPG"));
     
    		label3 = new JLabel("Choisissez votre categorie musicale");
    		label1.setForeground(Color.BLACK);
    		label2 = new JLabel("    ");
     
    		paneln.add(image);
    		paneln.add(label1);
     
    		brap = new JButton("RAP");
    		brap.setForeground(Color.yellow);
    		brap.setBackground(Color.BLACK);
    		brap.addActionListener(this);
    		brnb = new JButton("RNB");
    		brnb.setForeground(Color.yellow);
    		brnb.setBackground(Color.BLACK);
    		brnb.addActionListener(this);
    		bsalsa = new JButton("SALSA");
    		bsalsa.setForeground(Color.yellow);
    		bsalsa.setBackground(Color.BLACK);
    		bsalsa.addActionListener(this);
    		bjazz = new JButton("JAZZ");
    		bjazz.setForeground(Color.yellow);
    		bjazz.setBackground(Color.BLACK);
    		bjazz.addActionListener(this);
    		bnext = new JButton("Next");
    		bnext.setBackground(Color.YELLOW);
    		bnext.addActionListener(this);
    		bfirst = new JButton("First");
    		bfirst.setForeground(Color.yellow);
    		bfirst.setBackground(Color.BLACK);
    		bfirst.addActionListener(this);
    		blast = new JButton("Last");
    		blast.setBackground(Color.YELLOW);
    		blast.addActionListener(this);
    		bprevious = new JButton("Previous");
    		bprevious.setForeground(Color.yellow);
    		bprevious.setBackground(Color.BLACK);
    		bprevious.addActionListener(this);
    		binsert = new JButton("Inserer");
    		binsert.setBackground(Color.YELLOW);
    		binsert.addActionListener(this);
    		bdelete = new JButton("Supprimer");
    		bdelete.setForeground(Color.yellow);
    		bdelete.setBackground(Color.BLACK);
    		bdelete.addActionListener(this);
     
    		panel1.add(image);
    		panel1.add(label3);
    		panel1.add(brap);
    		panel1.add(brnb);
    		panel1.add(bsalsa);
    		panel1.add(bjazz);
     
    		panel3 = new JPanel();
    		pan3 = new JPanel();
    		panel3.setLayout(null);
    		panel3.setBackground(Color.BLACK);
     
    		pan3.setLayout(null);
    		ltitre = new JLabel(
    				"Voici les titres disponibles dans cette gatégorie :");
    		ltitre.setForeground(Color.YELLOW);
     
    		// placement des composants grace a la methode setBounds
    		ltitre.setBounds(200, 25, 300, 250);
    		cb1 = new JCheckBox();
    		cb1.setBackground(Color.black);
    		cb1.setBounds(250, 200, 25, 25);
    		cb2 = new JCheckBox();
    		cb2.setBackground(Color.black);
    		cb2.setBounds(250, 225, 25, 25);
    		cb3 = new JCheckBox();
    		cb3.setBackground(Color.black);
    		cb3.setBounds(250, 250, 25, 25);
    		cb4 = new JCheckBox();
    		cb4.setBackground(Color.black);
    		cb4.setBounds(250, 275, 25, 25);
    		cb5 = new JCheckBox();
    		cb5.setBackground(Color.black);
    		cb5.setBounds(250, 300, 25, 25);
    		cb6 = new JCheckBox();
    		cb6.setBackground(Color.black);
    		cb6.setBounds(250, 325, 25, 25);
    		cb7 = new JCheckBox();
    		cb7.setBackground(Color.black);
    		cb7.setBounds(250, 350, 25, 25);
    		tf1 = new JTextField(20);
    		tf1.setBackground(Color.YELLOW);
    		tf1.setBounds(275, 200, 150, 25);
    		tf2 = new JTextField(20);
    		tf2.setBackground(Color.YELLOW);
    		tf2.setBounds(275, 225, 150, 25);
    		tf3 = new JTextField(20);
    		tf3.setBackground(Color.YELLOW);
    		tf3.setBounds(275, 250, 150, 25);
    		tf4 = new JTextField(20);
    		tf4.setBackground(Color.YELLOW);
    		tf4.setBounds(275, 275, 150, 25);
    		tf5 = new JTextField(20);
    		tf5.setBackground(Color.YELLOW);
    		tf5.setBounds(275, 300, 150, 25);
    		tf6 = new JTextField(20);
    		tf6.setBackground(Color.YELLOW);
    		tf6.setBounds(275, 325, 150, 25);
    		tf7 = new JTextField(20);
    		tf7.setBackground(Color.YELLOW);
    		tf7.setBounds(275, 350, 150, 25);
     
    		bnext.setBounds(75, 400, 150, 25);
    		bfirst.setBounds(200, 400, 150, 25);
    		blast.setBounds(325, 400, 150, 25);
    		bprevious.setBounds(450, 400, 150, 25);
    		binsert.setBounds(200, 450, 150, 25);
    		bdelete.setBounds(325, 450, 150, 25);
     
    		panel3.add(ltitre);
    		panel3.add(cb1);
    		panel3.add(cb2);
    		panel3.add(cb3);
    		panel3.add(cb4);
    		panel3.add(cb5);
    		panel3.add(cb6);
    		panel3.add(cb7);
    		panel3.add(tf1);
    		panel3.add(tf2);
    		panel3.add(tf3);
    		panel3.add(tf4);
    		panel3.add(tf5);
    		panel3.add(tf6);
    		panel3.add(tf7);
    		panel3.add(bnext);
    		panel3.add(bfirst);
    		panel3.add(blast);
    		panel3.add(bprevious);
    		panel3.add(binsert);
    		panel3.add(bdelete);
     
    		this.add(paneln, "North");
    		this.add(panel1, "West");
    		this.add(panel2, "South");
    		this.add(panel3, "Center");
    		try {
    			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			con = DriverManager.getConnection("jdbc:odbc:MyDataSource");
    			stat = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    					ResultSet.CONCUR_READ_ONLY);
     
    			System.out.println("Initialization complete");
    		} catch (Exception e) {
    			System.out.println("Error " + e);
    		}
     
    	}
     
    	public void changementimagerap() {
     
    		image3 = new JLabel(new ImageIcon("rihana.JPG"));
    		image3.setBounds(550, 200, 100, 300);
    		panel3.remove(imagerap1);
    		panel3.add(image3);
     
    		image4 = new JLabel(new ImageIcon("jayz.JPG"));
    		image4.setBounds(500, 140, 100, 300);
    		panel3.remove(imagerap2);
    		panel3.add(image4);
     
    		image5 = new JLabel(new ImageIcon("ti.JPG"));
    		image5.setBounds(600, 140, 100, 300);
    		panel3.remove(imagerap3);
    		panel3.add(image5);
     
    		image6 = new JLabel(new ImageIcon("akon.JPG"));
    		image6.setBounds(550, 75, 100, 300);
    		panel3.remove(imagerap4);
    		panel3.add(image6);
    	}
     
    	// cette methode se charge de reinitialiser les Labels a chaque clics de
    	// souris
    	public void changementimagernb() {
    		imagerap1 = new JLabel(new ImageIcon("eminem.JPG"));
    		imagerap1.setBounds(550, 200, 100, 300);
    		panel3.remove(image3);
    		panel3.add(imagerap1);
     
    		imagerap2 = new JLabel(new ImageIcon("50cent.JPG"));
    		imagerap2.setBounds(500, 140, 100, 300);
    		panel3.remove(image4);
    		panel3.add(imagerap2);
     
    		imagerap3 = new JLabel(new ImageIcon("dmx.JPG"));
    		imagerap3.setBounds(600, 140, 100, 300);
    		panel3.remove(image5);
    		panel3.add(imagerap3);
     
    		imagerap4 = new JLabel(new ImageIcon("diams.JPG"));
    		imagerap4.setBounds(550, 75, 100, 300);
    		panel3.remove(image6);
    		panel3.add(imagerap4);
     
    	}
     
    	// cette methode se charge de reinitialiser les Jcheckbox
    	public void initialiser() {
    		if (cb1.isSelected() == true) {
    			cb1.setSelected(false);
     
    		} else {
    		}
    		if (cb2.isSelected() == true) {
    			cb2.setSelected(false);
    		} else {
    		}
    		if (cb3.isSelected() == true) {
    			cb3.setSelected(false);
    		} else {
    		}
    		if (cb4.isSelected() == true) {
    			cb4.setSelected(false);
    		} else {
    		}
    		if (cb5.isSelected() == true) {
    			cb5.setSelected(false);
    		} else {
    		}
    		if (cb6.isSelected() == true) {
    			cb6.setSelected(false);
    		} else {
    		}
    		if (cb7.isSelected() == true) {
    			cb7.setSelected(false);
    		} else {
    		}
    	}
     
    	public void actionPerformed(ActionEvent ae) {
     
    		try {
     
    			if (ae.getSource() == brap) {
     
    				changementimagerap();
    				repaint();
    				initialiser();
     
    				rs = stat
    						.executeQuery("SELECT * FROM oeu_oeuvre where cat_id = 1");
    				rs.first();
    				tf1.setText(Integer.toString(rs.getInt(1)));
    				tf2.setText(rs.getString(2));
    				tf3.setText(rs.getString(3));
    				tf4.setText(rs.getString(4));
    				tf5.setText(Float.toString(rs.getFloat(5)));
    				tf6.setText(Float.toString(rs.getFloat(6)));
     
    			}
     
    			else {
    				if (ae.getSource() == brnb) {
     
    					changementimagernb();
    										repaint();
    					initialiser();
    					rs = stat
    							.executeQuery("SELECT * FROM oeu_oeuvre where cat_id = 2");
    					rs.first();
    					tf1.setText(Integer.toString(rs.getInt(1)));
    					tf2.setText(rs.getString(2));
    					tf3.setText(rs.getString(3));
    					tf4.setText(rs.getString(4));
    					tf5.setText(Float.toString(rs.getFloat(5)));
    					tf6.setText(Float.toString(rs.getFloat(6)));
     
    				} else {
    					if (ae.getSource() == bsalsa) {
    						repaint();
    						initialiser();
     
    						rs = stat
    								.executeQuery("SELECT * FROM oeu_oeuvre where cat_id = 3");
    						rs.first();
    						tf1.setText(Integer.toString(rs.getInt(1)));
    						tf2.setText(rs.getString(2));
    						tf3.setText(rs.getString(3));
    						tf4.setText(rs.getString(4));
    						tf5.setText(Float.toString(rs.getFloat(5)));
    						tf6.setText(Float.toString(rs.getFloat(6)));
     
    					} else {
    						if (ae.getSource() == bjazz) {
    							repaint();
    							initialiser();
    							rs = stat
    									.executeQuery("SELECT * FROM oeu_oeuvre where cat_id = 4");
    							rs.first();
    							tf1.setText(Integer.toString(rs.getInt(1)));
    							tf2.setText(rs.getString(2));
    							tf3.setText(rs.getString(3));
    							tf4.setText(rs.getString(4));
    							tf5.setText(Float.toString(rs.getFloat(5)));
    							tf6.setText(Float.toString(rs.getFloat(6)));
    						}
    						if (ae.getActionCommand() == "First") {
    							try {
    								rs.first();
    								tf1.setText(Integer.toString(rs.getInt(1)));
    								tf2.setText(rs.getString(2));
    								tf3.setText(rs.getString(3));
    								tf4.setText(rs.getString(4));
    								tf5.setText(Float.toString(rs.getFloat(5)));
    								tf6.setText(Float.toString(rs.getFloat(6)));
    							} catch (Exception e) {
    								System.out.println("Error : " + e);
    							}
    						}
    						if (ae.getActionCommand() == "Last") {
    							try {
    								rs.last();
    								tf1.setText(Integer.toString(rs.getInt(1)));
    								tf2.setText(rs.getString(2));
    								tf3.setText(rs.getString(3));
    								tf4.setText(rs.getString(4));
    								tf5.setText(Float.toString(rs.getFloat(5)));
    								tf6.setText(Float.toString(rs.getFloat(6)));
    							} catch (Exception e) {
    								System.out.println("Error : " + e);
    							}
    						}
    						if (ae.getActionCommand() == "Previous") {
    							try {
    								rs.previous();
    								tf1.setText(Integer.toString(rs.getInt(1)));
    								tf2.setText(rs.getString(2));
    								tf3.setText(rs.getString(3));
    								tf4.setText(rs.getString(4));
    								tf5.setText(Float.toString(rs.getFloat(5)));
    								tf6.setText(Float.toString(rs.getFloat(6)));
    							} catch (Exception e) {
    								System.out.println("Error : " + e);
    							}
    						}
    						if (ae.getActionCommand() == "Next") {
    							try {
    								rs.next();
    								tf1.setText(Integer.toString(rs.getInt(1)));
    								tf2.setText(rs.getString(2));
    								tf3.setText(rs.getString(3));
    								tf4.setText(rs.getString(4));
    								tf5.setText(Float.toString(rs.getFloat(5)));
    								tf6.setText(Float.toString(rs.getFloat(6)));
    							} catch (Exception e) {
    								System.out.println("Error : " + e);
    							}
    						}
     
    						if (ae.getActionCommand() == "Precedent") {
    							fond.play();
    						}
     
    						else {
    						}
     
    					}
     
    				}
    			}
     
    		} catch (Exception e) {
    		}
     
    		if (ae.getSource() == bajouter) {
    			bajouter.setVisible(false);
     
    			Fenetre2 fen2 = new Fenetre2();
    			this.remove(panel3);
    			repaint();
    			changement();
    			recuperation();
    		} else {
    		}
     
    	}
    	public void recuperation() {
     
    		lDonnees = new ArrayList<String>();
    		etat = cb1.getVerifyInputWhenFocusTarget();
    		if (etat == true){
    			txt1 = tf1.getText();
    			lDonnees.add(txt1);
    			System.out.println(txt1);
    		}
     
    	}
     
    	public void changement() {
     
    		JPanel panelz, panel2;
    		JLabel album, prixunit, lquant, total, lvide1, lvide2, lvide3, lvide4;
    		JComboBox quantite, quantite2, quantite3, quantite4, quantite5, quantite6, quantite7;
    		JButton comander;
     
    		/*
    		 * public void initialisation () {
    		 */
    		this.setLayout(new BorderLayout());
    		panelz = new JPanel();
    		panelz.setLayout(null);
    		panel2 = new JPanel();
    		panel2.setLayout(new GridLayout(1, 5));
    		lvide1 = new JLabel("    ");
    		lvide2 = new JLabel("    ");
    		lvide3 = new JLabel("    ");
    		lvide4 = new JLabel("    ");
    		comander = new JButton("Commander");
    		panel2.add(lvide1);
    		panel2.add(lvide2);
    		panel2.add(lvide3);
    		panel2.add(lvide4);
    		panel2.add(comander);
    		album = new JLabel("ALBUM");
    		album.setBounds(300, 200, 75, 25);
    		lquant = new JLabel("Quantité");
    		prixunit = new JLabel("Prix Unitaire");
     
    		// comader.setSize(10,25);
    		comander.setBounds(600, 500, 75, 25);
    		prixunit.setBounds(450, 200, 75, 25);
    		lquant.setBounds(600, 200, 75, 25);
    		quantite = new JComboBox();
    		quantite.setBounds(588, 225, 75, 20);
    		quantite2 = new JComboBox();
    		quantite2.setBounds(588, 250, 75, 20);
    		quantite3 = new JComboBox();
    		quantite3.setBounds(588, 275, 75, 20);
    		quantite4 = new JComboBox();
    		quantite4.setBounds(588, 300, 75, 20);
    		quantite5 = new JComboBox();
    		quantite5.setBounds(588, 325, 75, 20);
    		quantite6 = new JComboBox();
    		quantite6.setBounds(588, 350, 75, 20);
    		quantite7 = new JComboBox();
    		quantite7.setBounds(588, 375, 75, 20);
     
    		total = new JLabel("Total");
    		total.setBounds(700, 200, 75, 25);
    		panelz.add(album);
    		panelz.add(prixunit);
    		panelz.add(lquant);
    		panelz.add(quantite);
    		panelz.add(quantite2);
    		panelz.add(quantite3);
    		panelz.add(quantite4);
    		panelz.add(quantite5);
    		panelz.add(quantite6);
    		panelz.add(quantite7);
    		panelz.add(quantite);
    		panelz.add(total);
     
    		this.add(panelz, "Center");
    		this.add(panel2, "South");
     
    	}
     
    }
    Ce que je veux c'est récupérer les valeurs correspondants aux JCheckBox coché et le transmettre à une autre applet

    Merci c

  2. #2
    Membre Expert
    Avatar de krachik
    Inscrit en
    Décembre 2004
    Messages
    1 964
    Détails du profil
    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 964
    Par défaut
    Bonjour

    J'ai pas parcouru le code en fond mais, je crois que si tu as associés les diffrents checkbox aux differents textfield ça devrait passer non?
    Ton soucis est de recuperer les differentes valeurs ou le soucis de le transmettre a une autre applet?

  3. #3
    Membre averti
    Inscrit en
    Août 2008
    Messages
    35
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 35
    Par défaut Récupèrer valeur JCheckBox
    Bonjour krachik

    Merci d'avoir bien voulu répondre à ma demande

    Au fait j'ai des soucis pour les deux à savoir:

    1_ comment récupere les valeur (parce que à priori je ne sais pas comment associer les checkbox aux textfield )

    2_ je ne sais pas aussi comment àprés récupération transferer les infos à un autre applet.

    Et merci encore une fois

  4. #4
    Membre Expert
    Avatar de krachik
    Inscrit en
    Décembre 2004
    Messages
    1 964
    Détails du profil
    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 964
    Par défaut
    Bonjour
    1. Pour communiquer entre 2 applets
    2. Pour associer les checkbox au textfield tu as plusieurs façons de les recuperer. Supposons par exemple que tu as 1, 2, 3 checkbox et que tu as 1_1,2_2,3_3 textfield bah quand tu parcours tes checkbox quand 1 est choché tu fais un getText() sur le textfield 1_1, si 3 est coché tu fais un getText() sur le 3_3 ainsi de suite, Mais je suppose que tes checkbox sont fixes ou bien ils sont dynamiques?
      Tu peux aussi te servir de liste ou de hashmap pour faire l'association , tu as le choix


    Cordialement

  5. #5
    Membre averti
    Inscrit en
    Août 2008
    Messages
    35
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 35
    Par défaut Recupération valeur JCheckBox
    Merci encore une fois

    Ce qui sera dans mes Textbox est dynamique parce que provenant de la base de données.

    En fait cela dépend des boutons rap salsa... et à partir de là je peux itérer sur les occurences provenant de la base de données

    Merci

  6. #6
    Membre averti
    Inscrit en
    Août 2008
    Messages
    35
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 35
    Par défaut Parcours des JCheckBox
    Bonjour

    J'ai un souci parcours mes JCheckBox j'ai creer cette methode mais elle ne parcourt pas tout mes checkbox j'ai essayé de faire comme tu m'as demandé

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 ArrayList getListeValeur() {
     
    		ArrayList mesInfos = new ArrayList<String>();
    		if (cb1.isSelected() == true) {	
    			tf1.getText();
    			mesInfos.add(tf1.getText());
    		} else {
    		}
    		if (cb2.isSelected() == true) {
    			tf2.getText();
    			mesInfos.add(tf2.getText());;
    		} else {
    		}
    		if (cb3.isSelected() == true) {
    			tf3.getText();
    			mesInfos.add(tf3.getText());
    		} else {
    		}
    		if (cb4.isSelected() == true) {
    			tf4.getText();
    			mesInfos.add(tf4.getText());
    		} else {
    		}
    		if (cb5.isSelected() == true) {
    			tf5.getText();
    			mesInfos.add(tf5.getText());
    		} else {
    		}
    		if (cb6.isSelected() == true) {
    			tf6.getText();
    			mesInfos.add(tf6.getText());
    		} else {
    		}
    		if (cb7.isSelected() == true) {
    			tf7.getText();
    			mesInfos.add(tf7.getText());
    		} else {
    		}
    		return mesInfos;
    	}
    Mon souci c'est sur qu'est ce qui sera mon curseur pour utiliser une boucle afin de parcourir mes checkbox

Discussions similaires

  1. comment recuperer valeur d'un champ Text
    Par ____22 dans le forum SWT/JFace
    Réponses: 4
    Dernier message: 13/03/2009, 10h13
  2. Réponses: 10
    Dernier message: 14/03/2008, 18h10
  3. Réponses: 5
    Dernier message: 17/06/2005, 16h17
  4. comment recuperer deux valeurs de deux champs input
    Par trialrofr dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 01/02/2005, 22h08
  5. Picklist: comment recuperer une partie de la valeur
    Par mesquest dans le forum Bases de données
    Réponses: 3
    Dernier message: 07/06/2004, 08h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo