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

AWT/Swing Java Discussion :

Grille affichage agents


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Février 2006
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 62
    Par défaut Grille affichage agents
    Bonjour,

    Je travaille sur un projet de simulation (systeme multigents) où je dois faire evoluer mes agents sur une carte (100x100 points).
    Pour cela, je dois construire une grille où chaque cellule a un arriere plan coloré qui represente le terrain (orange pour le desert par exemple).
    Chaque agent est représenté par une image disposée sur la cellule indiquant sa position.
    Plusieurs agents peuvent être présents sur une même cellule. Par conséquent, je dois pouvoir superposer des images sur mes cellules.

    Pouvez vous me dire quelle est la meilleur solution pour construire cette grille ? S'il existe un projet similaire ?

    Merci d'avance !

  2. #2
    Membre Expert
    Profil pro
    Fabrication GED
    Inscrit en
    Octobre 2005
    Messages
    1 405
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Fabrication GED

    Informations forums :
    Inscription : Octobre 2005
    Messages : 1 405
    Par défaut
    Comme ça à l'arrache, j'utiliserais un GridLayout de 100x100. Ensuite pour chaque case ( chaque panel du gridlayout ) on pourrait utiliser encore un gridlayout ou flowlayout etc.

  3. #3
    Membre confirmé
    Inscrit en
    Février 2006
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 62
    Par défaut
    Merci pour ta réponse !

    J'ai finalement opté pour un affichage sur une grille de dessin grace a la classe Canvas. C'est la solution la plus optimisée que j'ai trouvé !
    J'ai placé cette grille dans un JPanel qui lui même est inclu dans un JScrollPane de manière à ce que la taille de ma grille ne gêne pas la disposition des autres composants de mon interface graphique.
    Malheureusement, cette grille passe par dessus tous mes composants notamment par dessus les sous menus de mon application.
    Je pense que ça viens de la manière dont j'ai intégré mes barres de défilement.
    Quelqu'un peut m'aider?

    Voici un extrait de mon IHM:
    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
     
    	private JScrollPane getPnMap() {
    		if (pnMap == null) {
    			pnMap = new JScrollPane();
    			pnMap.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
    			pnMap.setViewportView(getJPanel6());
    		}
    		return pnMap;
    	}
     
    	private JPanel getJPanel6() {
    		if (jPanel6 == null) {
    			jPanel6 = new JPanel();
    			grid = new Grid(56,37,10,10);
    			grid.setName("grid");
    			grid.setBounds(new Rectangle(0, 0, 620, 414));
    			grid.addMouseListener(new java.awt.event.MouseAdapter() {
    				public void mouseClicked(java.awt.event.MouseEvent e) {
    					grid.setSelectedSquare(e.getX(),e.getY());
    					grid.repaint();
    				}
    			});
    			jPanel6.setLayout(null);
    			jPanel6.setBackground(Color.white);
    			jPanel6.add(grid, null);
    		}
    		return jPanel6;
    	}
    Ma classe grille:
    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
     
    import java.awt.*;
     
    public class Grid extends Canvas {
    	private static final long serialVersionUID = 1L;
     
    	public int cols;
    	public int rows;
    	public int square_w;
    	public int square_h;
    	public Point selected_square;
     
    	public Grid(int _cols, int _rows, int _square_w, int _square_h) {
    		cols = _cols;
    		rows = _rows;
    		square_h = _square_h;
    		square_w = _square_w;
    		setSize(cols * square_w+1, rows * square_h+1);
    		setBackground(Color.WHITE);	
    	}
     
        public void paint(Graphics g) {
        	//Draw the grid
        	g.setColor(Color.GRAY);
        	for (int i = 0; i <= rows; i++)
    		    g.drawLine(0, i*square_h+i, cols*square_w+cols, i*square_h+i);
    		for (int i = 0; i <= cols; i++)
    		    g.drawLine(i*square_w+i, 0, i*square_w+i, rows*square_h+rows);
    		g.setColor(Color.WHITE);
    		for (int i = 0; i <= cols; i++)
    			for (int j = 0; j <= rows; j++)
    				g.fillRect(i*square_w+1+i, j+j*square_h+1, 10, 10);
    		if (selected_square != null) {
    			g.setColor(Color.RED);
    			g.fillRect((int)selected_square.getX()*square_w+1+(int)selected_square.getX(), (int)selected_square.getY()+(int)selected_square.getY()*square_h+1, 10, 10);
    		}
    		Toolkit tk = Toolkit.getDefaultToolkit();
    		Image img = tk.getImage("C:/Documents and Settings/Eric/workspace2/Ecosystem Simulation/images/plus.gif");
    		g.drawImage(img, 12, 12, 10, 10, this);
        }
     
    	public void setSelectedSquare(int x, int y) {
    		selected_square = new Point((int)(x/(square_w+1)),(int)(y/(square_h+1)));
    	}
    }

  4. #4
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    là tu mélanges AWT et Swing, ce qui est définitivement pas top.
    http://java.developpez.com/faq/gui/?..._melange_SWING


    Au lieu d'utiliser Canvas pour dessiner ta grille utilises un JPanel. Il te suffit pour celà de remplacer extends Canvas par extends JPanel et de renommer ta méthode paint en paintComponent,


    deuxièmement dans ton paint tu charges l'image à chaque fois et ça c'est mal, tu rique de faire ramer ton appli comme pas peris, charges plutôt ton image une seule fois dans le constructeur et basta

  5. #5
    Membre confirmé
    Inscrit en
    Février 2006
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 62
    Par défaut
    Je viens de tout passer en SWING et en effet je n'ai plus de probleme et l'affichage est même plus rapide ! Encore merci sinok !
    En ce que concerne le reaffichage de l'image, c'était juste un test. Toutefois, je serais obligé de réafficher ma map entiere a chaque fois dans la mesure ou la position de mes nombreux agents est le type de terrain changera toutes les x secondes.
    Il me reste juste un petit problème a régler : lorsque que diminus la taille de ma fenêtre pour faire appraitre mes barres de defilement, mon panneau SUD-OUEST s'agrandit comme vous pouvez le voir sur ces deux captures. Je précise que tout est géré en GridBagLayout.
    Taille non reduite


    Taille reduite

  6. #6
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    Quel layout utilises tu?

  7. #7
    Membre confirmé
    Inscrit en
    Février 2006
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 62
    Par défaut
    Pour mon panel principal, j'utilise un GridBagLayout.
    Le JSrollPane qui contient la map a son anchor sur NORTHWEST et un fill sur BOTH
    Mon panel propriété a son anchor sur SOUTHWEST et un fill sur HORIZONTAL.

    Voici mon code complet si ca vous interesse :
    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
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
     
    import javax.swing.SwingUtilities;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import java.awt.Rectangle;
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import java.awt.Font;
    import javax.swing.SwingConstants;
    import java.awt.event.KeyEvent;
    import javax.swing.ImageIcon;
    import javax.swing.JSlider;
    import javax.swing.BorderFactory;
    import java.awt.Color;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.Dimension;
    import javax.swing.BoxLayout;
    import java.awt.FlowLayout;
     
    public class MainFrame extends JFrame {
     
    	private static final long serialVersionUID = 1L;
     
    	private JPanel pnContent = null;
     
    	private JMenuBar jJMenuBar = null;
     
    	private JMenu jMenu = null;
     
    	private JMenuItem jMenuItem = null;
     
    	private JPanel pnProperties = null;
     
    	private JPanel pnTime = null;
     
    	private JPanel pnEnvironnment = null;
     
    	private JTextField tfAgentName = null;
     
    	private JLabel lblAgentPicture = null;
     
    	private JLabel lblAgentProperties = null;
     
    	private JLabel lblPlay = null;
     
    	private JSlider sdSpeed = null;
     
    	private JSlider sdTime = null;
     
    	private JLabel lblTimeSpeed = null;
     
    	private JLabel lblTimeTime = null;
     
    	private JLabel lblTimeSpeedCur = null;
     
    	private JLabel lblTimeTimeCur = null;
     
    	private JLabel lblAgentMinus = null;
     
    	private JLabel lblAgentPlus = null;
     
    	private JScrollPane pnMap = null;
     
    	private JPanel jPanel = null;
     
    	private JScrollPane jScrollPane = null;
     
    	private JPanel jPanel1 = null;
     
    	private JPanel jPanel2 = null;
     
    	private JLabel jLabel = null;
     
    	private JTextField jTextField = null;
     
    	private JTextField jTextField1 = null;
     
    	private JLabel jLabel1 = null;
     
    	private JLabel jLabel2 = null;
     
    	private JTextField jTextField2 = null;
     
    	private JLabel jLabel3 = null;
     
    	private JLabel jLabel4 = null;
     
    	private JLabel jLabel5 = null;
     
    	private JTextField jTextField3 = null;
     
    	private JTextField jTextField4 = null;
     
    	private JTextField jTextField5 = null;
     
    	private JPanel jPanel3 = null;
     
    	private JPanel jPanel4 = null;
     
    	private JLabel jLabel6 = null;
     
    	private JPanel jPanel5 = null;
     
    	private JLabel jLabel7 = null;
     
    	private JPanel jPanel6 = null;
     
    	private Grid grid = null;
     
    	/**
             * This method initializes jJMenuBar    
             *      
             * @return javax.swing.JMenuBar 
             */
    	private JMenuBar getJJMenuBar() {
    		if (jJMenuBar == null) {
    			jJMenuBar = new JMenuBar();
    			jJMenuBar.add(getJMenu());
    		}
    		return jJMenuBar;
    	}
     
    	/**
             * This method initializes jMenu        
             *      
             * @return javax.swing.JMenu    
             */
    	private JMenu getJMenu() {
    		if (jMenu == null) {
    			jMenu = new JMenu();
    			jMenu.setText("File");
    			jMenu.add(getJMenuItem());
    		}
    		return jMenu;
    	}
     
    	/**
             * This method initializes jMenuItem    
             *      
             * @return javax.swing.JMenuItem        
             */
    	private JMenuItem getJMenuItem() {
    		if (jMenuItem == null) {
    			jMenuItem = new JMenuItem();
    			jMenuItem.setText("test");
    		}
    		return jMenuItem;
    	}
     
    	/**
             * This method initializes pnProperties 
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getPnProperties() {
    		if (pnProperties == null) {
    			GridBagConstraints gridBagConstraints25 = new GridBagConstraints();
    			gridBagConstraints25.gridx = 0;
    			gridBagConstraints25.gridy = 0;
    			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
    			gridBagConstraints6.insets = new Insets(0, 0, 0, 0);
    			gridBagConstraints6.gridx = 2;
    			gridBagConstraints6.gridy = 0;
    			gridBagConstraints6.anchor = GridBagConstraints.NORTH;
    			gridBagConstraints6.fill = GridBagConstraints.BOTH;
    			gridBagConstraints6.gridwidth = 1;
    			gridBagConstraints6.ipadx = 150;
    			gridBagConstraints6.weightx = 1.0;
    			gridBagConstraints6.ipady = 0;
    			gridBagConstraints6.gridheight = 2;
    			lblAgentPlus = new JLabel();
    			lblAgentPlus.setIcon(new ImageIcon("C:/Documents and Settings/Eric/workspace2/Ecosystem Simulation/images/plus.gif"));
    			lblAgentPlus.setToolTipText("Add a copy of this agent");
    			lblAgentPlus.setText("");
    			lblAgentMinus = new JLabel();
    			lblAgentMinus.setIcon(new ImageIcon("C:/Documents and Settings/Eric/workspace2/Ecosystem Simulation/images/minus.gif"));
    			lblAgentMinus.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
     
    			lblAgentMinus.setToolTipText("Remove this agent");
    			lblAgentMinus.setText("");
    			lblAgentProperties = new JLabel();
    			lblAgentProperties.setText("------ Agent Properties ------");
    			lblAgentProperties.setHorizontalAlignment(SwingConstants.CENTER);
    			lblAgentPicture = new JLabel();
    			lblAgentPicture.setHorizontalTextPosition(SwingConstants.CENTER);
    			lblAgentPicture.setHorizontalAlignment(SwingConstants.CENTER);
    			lblAgentPicture.setFont(new Font("Dialog", Font.PLAIN, 12));
    			lblAgentPicture.setText("No image");
    			pnProperties = new JPanel();
    			pnProperties.setLayout(new GridBagLayout());
    			pnProperties.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
    			pnProperties.setPreferredSize(new Dimension(0, 0));
    			pnProperties.add(getJPanel1(), gridBagConstraints6);
    			pnProperties.add(getJPanel3(), gridBagConstraints25);
    		}
    		return pnProperties;
    	}
     
    	/**
             * This method initializes pnTime       
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getPnTime() {
    		if (pnTime == null) {
    			lblTimeTimeCur = new JLabel();
    			lblTimeTimeCur.setBounds(new Rectangle(134, -1, 26, 14));
    			lblTimeTimeCur.setHorizontalAlignment(SwingConstants.RIGHT);
    			lblTimeTimeCur.setText("50");
    			lblTimeTimeCur.setFont(new Font("Dialog", Font.PLAIN, 10));
    			lblTimeSpeedCur = new JLabel();
    			lblTimeSpeedCur.setBounds(new Rectangle(69, -3, 22, 17));
    			lblTimeSpeedCur.setFont(new Font("Dialog", Font.PLAIN, 10));
    			lblTimeSpeedCur.setHorizontalAlignment(SwingConstants.RIGHT);
    			lblTimeSpeedCur.setText("50");
    			lblTimeTime = new JLabel();
    			lblTimeTime.setBounds(new Rectangle(100, -3, 29, 16));
    			lblTimeTime.setFont(new Font("Dialog", Font.PLAIN, 10));
    			lblTimeTime.setHorizontalAlignment(SwingConstants.LEFT);
    			lblTimeTime.setText("Time:");
    			lblTimeSpeed = new JLabel();
    			lblTimeSpeed.setBounds(new Rectangle(32, -4, 34, 19));
    			lblTimeSpeed.setFont(new Font("Dialog", Font.PLAIN, 10));
    			lblTimeSpeed.setHorizontalAlignment(SwingConstants.LEFT);
    			lblTimeSpeed.setText("Speed:");
    			lblPlay = new JLabel();
    			lblPlay.setIcon(new ImageIcon("C:/Documents and Settings/Eric/workspace2/Ecosystem Simulation/images/play.gif"));
    			lblPlay.setBounds(new Rectangle(4, 6, 20, 17));
    			lblPlay.addMouseListener(new java.awt.event.MouseAdapter() {
    				public void mouseClicked(java.awt.event.MouseEvent e) {
    					lblPlay.setIcon(new ImageIcon("C:/Documents and Settings/Eric/workspace2/Ecosystem Simulation/images/pause.gif"));
    				}
    			});
    			pnTime = new JPanel();
    			pnTime.setLayout(null);
    			pnTime.add(lblPlay, null);
    			pnTime.add(getSdSpeed(), null);
    			pnTime.add(getSdTime(), null);
    			pnTime.add(lblTimeSpeed, null);
    			pnTime.add(lblTimeTime, null);
    			pnTime.add(lblTimeSpeedCur, null);
    			pnTime.add(lblTimeTimeCur, null);
    		}
    		return pnTime;
    	}
     
    	/**
             * This method initializes pnEnvironnment       
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getPnEnvironnment() {
    		if (pnEnvironnment == null) {
    			jLabel7 = new JLabel();
    			jLabel7.setBounds(new Rectangle(4, 2, 158, 16));
    			jLabel7.setHorizontalAlignment(SwingConstants.CENTER);
    			jLabel7.setText("------ Environment ------");
    			pnEnvironnment = new JPanel();
    			pnEnvironnment.setLayout(null);
    			pnEnvironnment.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
    			pnEnvironnment.add(jLabel7, null);
    		}
    		return pnEnvironnment;
    	}
     
    	/**
             * This method initializes tfAgentName  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getTfAgentName() {
    		if (tfAgentName == null) {
    			tfAgentName = new JTextField();
    			tfAgentName.setFont(new Font("Dialog", Font.PLAIN, 12));
    			tfAgentName.setPreferredSize(new Dimension(84, 20));
    			tfAgentName.setToolTipText("Agent name");
    			tfAgentName.setText("Name");
    		}
    		return tfAgentName;
    	}
     
    	/**
             * This method initializes sdSpeed      
             *      
             * @return javax.swing.JSlider  
             */
    	private JSlider getSdSpeed() {
    		if (sdSpeed == null) {
    			sdSpeed = new JSlider();
    			sdSpeed.setBounds(new Rectangle(26, 12, 73, 16));
    			sdSpeed.addChangeListener(new javax.swing.event.ChangeListener() {
    				public void stateChanged(javax.swing.event.ChangeEvent e) {
    					lblTimeSpeedCur.setText(""+sdSpeed.getValue());
    				}
    			});
    		}
    		return sdSpeed;
    	}
     
    	/**
             * This method initializes sdTime       
             *      
             * @return javax.swing.JSlider  
             */
    	private JSlider getSdTime() {
    		if (sdTime == null) {
    			sdTime = new JSlider();
    			sdTime.setBounds(new Rectangle(94, 12, 73, 16));
    			sdTime.addChangeListener(new javax.swing.event.ChangeListener() {
    				public void stateChanged(javax.swing.event.ChangeEvent e) {
    					lblTimeTimeCur.setText(""+sdTime.getValue());
    				}
    			});
    		}
    		return sdTime;
    	}
     
    	/**
             * This method initializes pnMap        
             *      
             * @return javax.swing.JScrollPane      
             */
    	private JScrollPane getPnMap() {
    		if (pnMap == null) {
    			pnMap = new JScrollPane();
    			pnMap.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
    			pnMap.setViewportView(getJPanel6());
    		}
    		return pnMap;
    	}
     
    	/**
             * This method initializes jPanel       
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel() {
    		if (jPanel == null) {
    			GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
    			gridBagConstraints8.gridx = 0;
    			gridBagConstraints8.gridy = 2;
    			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    			gridBagConstraints7.gridx = 0;
    			gridBagConstraints7.gridy = 1;
    			jLabel6 = new JLabel();
    			jLabel6.setText("------ Agent list ------");
    			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    			gridBagConstraints3.fill = GridBagConstraints.BOTH;
    			gridBagConstraints3.gridy = 3;
    			gridBagConstraints3.weightx = 1.0;
    			gridBagConstraints3.weighty = 1.0;
    			gridBagConstraints3.insets = new Insets(0, 2, 0, 0);
    			gridBagConstraints3.gridx = 0;
    			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
    			gridBagConstraints2.anchor = GridBagConstraints.NORTH;
    			gridBagConstraints2.insets = new Insets(2, 2, 1, 2);
    			gridBagConstraints2.gridx = 0;
    			gridBagConstraints2.gridy = 0;
    			gridBagConstraints2.ipadx = 164;
    			gridBagConstraints2.ipady = 29;
    			gridBagConstraints2.fill = GridBagConstraints.NONE;
    			jPanel = new JPanel();
    			jPanel.setLayout(new GridBagLayout());
    			jPanel.add(getPnTime(), gridBagConstraints2);
    			jPanel.add(getJScrollPane(), gridBagConstraints3);
    			jPanel.add(jLabel6, gridBagConstraints7);
    			jPanel.add(getJPanel5(), gridBagConstraints8);
    		}
    		return jPanel;
    	}
     
    	/**
             * This method initializes jScrollPane  
             *      
             * @return javax.swing.JScrollPane      
             */
    	private JScrollPane getJScrollPane() {
    		if (jScrollPane == null) {
    			jScrollPane = new JScrollPane();
    		}
    		return jScrollPane;
    	}
     
    	/**
             * This method initializes jPanel1      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel1() {
    		if (jPanel1 == null) {
    			jLabel3 = new JLabel();
    			jLabel3.setText("JLabel");
    			jPanel1 = new JPanel();
    			jPanel1.setLayout(new BoxLayout(getJPanel1(), BoxLayout.Y_AXIS));
    			jPanel1.setPreferredSize(new Dimension(0, 0));
    			jPanel1.add(getJPanel4(), null);
    			jPanel1.add(getJPanel2(), null);
    		}
    		return jPanel1;
    	}
     
    	/**
             * This method initializes jPanel2      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel2() {
    		if (jPanel2 == null) {
    			GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
    			gridBagConstraints24.fill = GridBagConstraints.BOTH;
    			gridBagConstraints24.anchor = GridBagConstraints.CENTER;
    			GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
    			gridBagConstraints23.fill = GridBagConstraints.BOTH;
    			gridBagConstraints23.gridy = 1;
    			gridBagConstraints23.weightx = 1.0;
    			gridBagConstraints23.gridx = 5;
    			GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
    			gridBagConstraints22.fill = GridBagConstraints.BOTH;
    			gridBagConstraints22.gridy = 1;
    			gridBagConstraints22.weightx = 1.0;
    			gridBagConstraints22.gridx = 3;
    			GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
    			gridBagConstraints21.fill = GridBagConstraints.BOTH;
    			gridBagConstraints21.gridy = 1;
    			gridBagConstraints21.weightx = 1.0;
    			gridBagConstraints21.gridx = 1;
    			GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
    			gridBagConstraints20.gridx = 4;
    			gridBagConstraints20.fill = GridBagConstraints.VERTICAL;
    			gridBagConstraints20.gridy = 1;
    			jLabel5 = new JLabel();
    			jLabel5.setText("JLabel");
    			GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
    			gridBagConstraints19.gridx = 2;
    			gridBagConstraints19.fill = GridBagConstraints.VERTICAL;
    			gridBagConstraints19.gridy = 1;
    			jLabel4 = new JLabel();
    			jLabel4.setText("JLabel");
    			GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
    			gridBagConstraints18.gridx = 0;
    			gridBagConstraints18.anchor = GridBagConstraints.WEST;
    			gridBagConstraints18.fill = GridBagConstraints.BOTH;
    			gridBagConstraints18.gridy = 1;
    			GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
    			gridBagConstraints17.fill = GridBagConstraints.BOTH;
    			gridBagConstraints17.gridy = 0;
    			gridBagConstraints17.weightx = 1.0;
    			gridBagConstraints17.gridx = 5;
    			GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
    			gridBagConstraints16.gridx = 4;
    			gridBagConstraints16.fill = GridBagConstraints.VERTICAL;
    			gridBagConstraints16.gridy = 0;
    			jLabel2 = new JLabel();
    			jLabel2.setText("JLabel");
    			GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
    			gridBagConstraints14.gridx = 2;
    			gridBagConstraints14.fill = GridBagConstraints.VERTICAL;
    			gridBagConstraints14.gridy = 0;
    			jLabel1 = new JLabel();
    			jLabel1.setText("JLabel");
    			GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
    			gridBagConstraints15.fill = GridBagConstraints.BOTH;
    			gridBagConstraints15.gridy = 0;
    			gridBagConstraints15.weightx = 1.0;
    			gridBagConstraints15.gridx = 3;
    			GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
    			gridBagConstraints13.fill = GridBagConstraints.BOTH;
    			gridBagConstraints13.gridy = 0;
    			gridBagConstraints13.weightx = 1.0;
    			gridBagConstraints13.gridx = 1;
    			jLabel = new JLabel();
    			jLabel.setText("Teste de teste");
    			jPanel2 = new JPanel();
    			jPanel2.setLayout(new GridBagLayout());
    			jPanel2.add(jLabel, gridBagConstraints24);
    			jPanel2.add(getJTextField(), gridBagConstraints13);
    			jPanel2.add(getJTextField1(), gridBagConstraints15);
    			jPanel2.add(jLabel1, gridBagConstraints14);
    			jPanel2.add(jLabel2, gridBagConstraints16);
    			jPanel2.add(getJTextField2(), gridBagConstraints17);
    			jPanel2.add(jLabel3, gridBagConstraints18);
    			jPanel2.add(jLabel4, gridBagConstraints19);
    			jPanel2.add(jLabel5, gridBagConstraints20);
    			jPanel2.add(getJTextField3(), gridBagConstraints21);
    			jPanel2.add(getJTextField4(), gridBagConstraints22);
    			jPanel2.add(getJTextField5(), gridBagConstraints23);
    		}
    		return jPanel2;
    	}
     
    	/**
             * This method initializes jTextField   
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField() {
    		if (jTextField == null) {
    			jTextField = new JTextField();
    		}
    		return jTextField;
    	}
     
    	/**
             * This method initializes jTextField1  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField1() {
    		if (jTextField1 == null) {
    			jTextField1 = new JTextField();
    		}
    		return jTextField1;
    	}
     
    	/**
             * This method initializes jTextField2  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField2() {
    		if (jTextField2 == null) {
    			jTextField2 = new JTextField();
    		}
    		return jTextField2;
    	}
     
    	/**
             * This method initializes jTextField3  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField3() {
    		if (jTextField3 == null) {
    			jTextField3 = new JTextField();
    		}
    		return jTextField3;
    	}
     
    	/**
             * This method initializes jTextField4  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField4() {
    		if (jTextField4 == null) {
    			jTextField4 = new JTextField();
    		}
    		return jTextField4;
    	}
     
    	/**
             * This method initializes jTextField5  
             *      
             * @return javax.swing.JTextField       
             */
    	private JTextField getJTextField5() {
    		if (jTextField5 == null) {
    			jTextField5 = new JTextField();
    		}
    		return jTextField5;
    	}
     
    	/**
             * This method initializes jPanel3      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel3() {
    		if (jPanel3 == null) {
    			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    			gridBagConstraints5.anchor = GridBagConstraints.NORTHWEST;
    			gridBagConstraints5.gridwidth = 1;
    			gridBagConstraints5.gridx = 0;
    			gridBagConstraints5.gridy = 0;
    			gridBagConstraints5.ipadx = 46;
    			gridBagConstraints5.ipady = 85;
    			gridBagConstraints5.weightx = 100.0D;
    			gridBagConstraints5.fill = GridBagConstraints.VERTICAL;
    			gridBagConstraints5.insets = new Insets(0, 0, 0, 0);
    			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
    			gridBagConstraints4.anchor = GridBagConstraints.SOUTHWEST;
    			gridBagConstraints4.insets = new Insets(0, 0, 0, 0);
    			gridBagConstraints4.gridwidth = 1;
    			gridBagConstraints4.gridx = 0;
    			gridBagConstraints4.gridy = 1;
    			gridBagConstraints4.ipadx = 0;
    			gridBagConstraints4.weightx = 1.0;
    			gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
    			jPanel3 = new JPanel();
    			jPanel3.setLayout(new GridBagLayout());
    			jPanel3.add(getTfAgentName(), gridBagConstraints4);
    			jPanel3.add(lblAgentPicture, gridBagConstraints5);
    		}
    		return jPanel3;
    	}
     
    	/**
             * This method initializes jPanel4      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel4() {
    		if (jPanel4 == null) {
    			FlowLayout flowLayout = new FlowLayout();
    			flowLayout.setHgap(110);
    			flowLayout.setVgap(0);
    			jPanel4 = new JPanel();
    			jPanel4.setLayout(flowLayout);
    			jPanel4.add(lblAgentMinus, null);
    			jPanel4.add(lblAgentProperties, null);
    			jPanel4.add(lblAgentPlus, null);
    		}
    		return jPanel4;
    	}
     
    	/**
             * This method initializes jPanel5      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel5() {
    		if (jPanel5 == null) {
    			jPanel5 = new JPanel();
    			jPanel5.setLayout(new GridBagLayout());
    		}
    		return jPanel5;
    	}
     
    	/**
             * This method initializes jPanel6      
             *      
             * @return javax.swing.JPanel   
             */
    	private JPanel getJPanel6() {
    		if (jPanel6 == null) {
    			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    			gridBagConstraints9.gridx = 0;
    			gridBagConstraints9.ipadx = 610;
    			gridBagConstraints9.ipady = 404;
    			gridBagConstraints9.gridy = 0;
    			jPanel6 = new JPanel();
    			grid = new Grid(56,37,10,10);
    			grid.setName("grid");
    			grid.setBackground(Color.WHITE);
    			grid.addMouseListener(new java.awt.event.MouseAdapter() {
    				public void mouseClicked(java.awt.event.MouseEvent e) {
    					grid.setSelectedSquare(e.getX(),e.getY());
    					grid.repaint();
    				}
    			});
    			jPanel6.setLayout(new GridBagLayout());
    			jPanel6.add(grid, gridBagConstraints9);
    		}
    		return jPanel6;
    	}
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		SwingUtilities.invokeLater(new Runnable() {
    			public void run() {
    				MainFrame thisClass = new MainFrame();
    				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    				thisClass.setVisible(true);
    			}
    		});
    	}
     
    	/**
             * This is the default constructor
             */
    	public MainFrame() {
    		super();
    		initialize();
    	}
     
    	/**
             * This method initializes this
             * 
             * @return void
             */
    	private void initialize() {
    		this.setSize(800, 600);
    		this.setJMenuBar(getJJMenuBar());
    		this.setContentPane(getPnContent());
    		this.setTitle("EcoSimul");
    		this.setVisible(true);
    	}
     
    	/**
             * This method initializes pnContent
             * 
             * @return javax.swing.JPanel
             */
    	private JPanel getPnContent() {
    		if (pnContent == null) {
    			GridBagConstraints gridBagConstraints = new GridBagConstraints();
    			gridBagConstraints.gridx = 2;
    			gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
    			gridBagConstraints.fill = GridBagConstraints.BOTH;
    			gridBagConstraints.gridy = 1;
    			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
    			gridBagConstraints12.fill = GridBagConstraints.BOTH;
    			gridBagConstraints12.gridy = 0;
    			gridBagConstraints12.weightx = 1.0;
    			gridBagConstraints12.weighty = 1.0;
    			gridBagConstraints12.gridheight = 2;
    			gridBagConstraints12.anchor = GridBagConstraints.NORTHWEST;
    			gridBagConstraints12.gridwidth = 2;
    			gridBagConstraints12.insets = new Insets(1, 1, 1, 0);
    			gridBagConstraints12.gridx = 0;
    			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
    			gridBagConstraints11.anchor = GridBagConstraints.SOUTHEAST;
    			gridBagConstraints11.insets = new Insets(0, 0, 1, 1);
    			gridBagConstraints11.gridx = 2;
    			gridBagConstraints11.gridy = 2;
    			gridBagConstraints11.ipadx = 165;
    			gridBagConstraints11.ipady = 122;
    			gridBagConstraints11.fill = GridBagConstraints.NONE;
    			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    			gridBagConstraints1.insets = new Insets(1, 1, 1, 0);
    			gridBagConstraints1.gridy = 2;
    			gridBagConstraints1.ipadx = 0;
    			gridBagConstraints1.ipady = 123;
    			gridBagConstraints1.anchor = GridBagConstraints.SOUTHWEST;
    			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    			gridBagConstraints1.gridwidth = 2;
    			gridBagConstraints1.gridheight = 1;
    			gridBagConstraints1.gridx = 0;
    			pnContent = new JPanel();
    			pnContent.setLayout(new GridBagLayout());
    			pnContent.setName("");
    			pnContent.add(getPnProperties(), gridBagConstraints1);
    			pnContent.add(getPnEnvironnment(), gridBagConstraints11);
    			pnContent.add(getPnMap(), gridBagConstraints12);
    			pnContent.add(getJPanel(), gridBagConstraints);
    		}
    		return pnContent;
    	}
     
    }

Discussions similaires

  1. Affichage d'une grille en Java
    Par chocoboy dans le forum Graphisme
    Réponses: 15
    Dernier message: 04/09/2014, 23h43
  2. [Lazarus] Affichage d'une grille d'images
    Par Brupio dans le forum Lazarus
    Réponses: 1
    Dernier message: 01/04/2007, 15h42
  3. [MySQL] Dating Agent Pro et affichage
    Par mickado dans le forum PHP & Base de données
    Réponses: 33
    Dernier message: 24/01/2007, 15h38
  4. Réponses: 3
    Dernier message: 19/07/2006, 10h16
  5. [Débutant] Affichage d'une grille
    Par Mathieu.J dans le forum OpenGL
    Réponses: 25
    Dernier message: 13/06/2004, 19h38

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