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 :

gestion des fenêtres en java


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Mars 2008
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 21
    Par défaut gestion des fenêtres en java
    bonjour tous,

    voila j'ai un problème dans une petite application que j'ai crée j'ai
    une fenêtre principale,une autre fenêtre qui s'affiche lorsque je clic sur un bouton(se trouve dans la fenêtre principale) le problème je veux que le "contenu de la fenêtre secondaire" s'affiche dans la fenêtre principale se que j'ai fais est de mettre un Container comme paramètre dans la fenêtre secondaire voila:


    new Graphe(contenu).show();

    si quelqu'un à une idée je serais reconnaissant merci

  2. #2
    Membre émérite Avatar de jojodu31
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    875
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Mars 2008
    Messages : 875
    Par défaut
    bonjoour pourrais tu poster ton code stp ?
    sinon je pense que tu devrais t'en sortir en récupérant le contenu du panneau2 que tu passe au panneau 1...enfin dit comme ça c'est peut etre pas très clair
    j'attend le code

  3. #3
    Membre averti
    Inscrit en
    Mars 2008
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 21
    Par défaut
    bonjour jojodu31,
    est ce que tu pe m'expliquer en un exemple trés simple entre deux fenétre et me l'envoyer ,merci.
    voila ma class FenCombo

    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
    /*** class principal***/
     
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import javax.swing.filechooser.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.geom.Rectangle2D;
     
     
     
    public class FenCombo extends JFrame implements ActionListener 
     
    {
    	setTitle("graphe");
        setSize(500,500);
     Container contenu = getContentPane();	
     
     
     
    	public FenCombo()
    {
    	panCom=new JPanel();
    contenu.add (panCom,"South");
     
    	dim=new JButton("afficher le graphe");
     
    			dim.setActionCommand("boutonExit");
    			dim.addActionListener(this);
    panCom.add(dim);
    	public void actionPerformed(ActionEvent e) {
     		if (e.getSource()==dim){ new Graphe(contenu).show();}
    		}
     
    		private JButton dim;
     
    		public static void main (String args[])
    {
    	   FenCombo fen=new FenCombo();
           fen.setVisible(true);
     
     
    }
     
    /**************voila ma class secondaire*************/
     
     
             class Graphe
     
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.geom.Rectangle2D;
    import org.jgraph.JGraph; 
    import org.jgraph.graph.DefaultEdge;
    import org.jgraph.graph.DefaultGraphCell;
    import org.jgraph.graph.DefaultGraphModel;
    import org.jgraph.graph.DefaultPort;
    import org.jgraph.graph.GraphConstants;
    import org.jgraph.graph.GraphModel;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import javax.swing.filechooser.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.geom.Rectangle2D;
     
     
     public class Graphe extends JFrame  {
    	Container contenur;
    	public Graphe(Container contenur){
    			this.contenur=contenur;
     
    		setTitle("Graphe");
        	contenur.setSize(200,150);
            contenur = getContentPane();
     
     
     
    GraphModel model = new DefaultGraphModel();
      JGraph graph = new JGraph(model);
     
    // Control-drag should clone selection
    graph.setCloneable(false);
     
     
    // Enable edit without final RETURN keystroke
    graph.setInvokesStopCellEditing(true);
     
    // When over a cell, jump to its default port (we only have one, anyway)
    graph.setJumpToDefaultPort(true);
     
    // Insert all three cells in one call, so we need an array to store them
    DefaultGraphCell[] cells = new DefaultGraphCell[17];
     
     
    // Create Hello Vertex
    cells[0] = createVertex("(pere)", 500, 30, 120, 30, Color.BLUE, true);
     
    // Create World Vertex
    cells[1] = createVertex("(mere)", 5, 150, 120, 30, Color.BLUE, true);
     
    // Create World Vertex
    cells[2] = createVertex("(seour)", 200, 150, 120, 30, Color.BLUE, true);
     
    cells[3] = createVertex("(frére)", 395, 150, 120, 30, Color.ORANGE, true);
     
    cells[4] = createVertex("()", 590, 150, 120, 30, Color.ORANGE, true);
     
    cells[5] = createVertex("()", 200, 300, 120, 30, Color.ORANGE, true);
     
     
    cells[6] = createVertex("()", 395, 300, 120, 30, Color.ORANGE, true);
     
    cells[7] = createVertex("()", 590, 450, 120, 30, Color.ORANGE, true);
     
     
    // Create Edge création de vecteur
    DefaultEdge edge1 = new DefaultEdge();
    DefaultEdge edge2 = new DefaultEdge();
    DefaultEdge edge3 = new DefaultEdge();
    DefaultEdge edge4 = new DefaultEdge();
    DefaultEdge edge5 = new DefaultEdge();
    DefaultEdge edge6 = new DefaultEdge();
    DefaultEdge edge7 = new DefaultEdge();
    DefaultEdge edge8 = new DefaultEdge();
    DefaultEdge edge9 = new DefaultEdge();
     
    // Fetch the ports from the new vertices, and connect them with the edge
    edge1.setSource(cells[0].getChildAt(0));
    edge1.setTarget(cells[1].getChildAt(0));
    cells[8] = edge1;
     
     
    edge2.setSource(cells[0].getChildAt(0));
    edge2.setTarget(cells[2].getChildAt(0));
    cells[9]=edge2;
     
    edge3.setSource(cells[0].getChildAt(0));
    edge3.setTarget(cells[3].getChildAt(0));
    cells[10]=edge3;
     
     
    edge4.setSource(cells[0].getChildAt(0));
    edge4.setTarget(cells[4].getChildAt(0));
    cells[11]=edge4;
     
    edge5.setSource(cells[2].getChildAt(0));
    edge5.setTarget(cells[5].getChildAt(0));
    cells[12]=edge5;
     
    edge6.setSource(cells[3].getChildAt(0));
    edge6.setTarget(cells[6].getChildAt(0));
    cells[13]=edge6;
     
     
    edge7.setSource(cells[5].getChildAt(0));
    edge7.setTarget(cells[7].getChildAt(0));
    cells[14]=edge7;
     
     
    edge8.setSource(cells[4].getChildAt(0));
    edge8.setTarget(cells[7].getChildAt(0));
    cells[15]=edge8;
     
    edge9.setSource(cells[6].getChildAt(0));
    edge9.setTarget(cells[7].getChildAt(0));
    cells[16]=edge9;
    // Set Arrow Style for edge
    // Set Arrow Style for edge
    int arrow1 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge1.getAttributes(), arrow1);
    GraphConstants.setEndFill(edge1.getAttributes(), true);
    // Set Arrow Style for edge
    int arrow2 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge2.getAttributes(), arrow2);
    GraphConstants.setEndFill(edge2.getAttributes(), true);
     
    // Set Arrow Style for edge
    int arrow3 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge3.getAttributes(), arrow3);
    GraphConstants.setEndFill(edge3.getAttributes(), true);
     
    // Set Arrow Style for edge
    int arrow4 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge4.getAttributes(), arrow4);
    GraphConstants.setEndFill(edge4.getAttributes(), true);
     
     
    int arrow5 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge5.getAttributes(), arrow5);
    GraphConstants.setEndFill(edge5.getAttributes(), true);
     
    int arrow6 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge6.getAttributes(), arrow6);
    GraphConstants.setEndFill(edge6.getAttributes(), true);
     
    int arrow7 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge7.getAttributes(), arrow7);
    GraphConstants.setEndFill(edge7.getAttributes(), true);
     
    int arrow8 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge8.getAttributes(), arrow8);
    GraphConstants.setEndFill(edge8.getAttributes(), true);
     
    int arrow9 = GraphConstants.ARROW_CLASSIC;
    GraphConstants.setLineEnd(edge9.getAttributes(), arrow9);
    GraphConstants.setEndFill(edge9.getAttributes(), true);
    // Insert the cells via the cache, so they get selected
    graph.getGraphLayoutCache().insert(cells);
     
    contenur.add(new JScrollPane(graph));
    pack();
     
     
     
    }
     
     
     
     
    public static DefaultGraphCell createVertex(String name, double x,double y, double w, double h, Color bg, boolean raised) {
     
    // Create vertex with the given name
    DefaultGraphCell cell = new DefaultGraphCell(name);
     
    // Set bounds
    GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(x, y, w, h));
     
     
     
    // Set fill color
    if (bg != null) {
    GraphConstants.setGradientColor(cell.getAttributes(), Color.blue);
    GraphConstants.setOpaque(cell.getAttributes(), true);
    }
     
    // Set raised border
    if (raised)
    GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createRaisedBevelBorder());
    else
    // Set black border
    GraphConstants.setBorderColor(cell.getAttributes(), Color.orange);
     
    // Add a Port
    DefaultPort port = new DefaultPort();
    cell.add(port);
    port.setParent(cell);
     
    return cell;
    }
     
    }

Discussions similaires

  1. Gestion des fenêtres avec les menus
    Par Death83 dans le forum C++Builder
    Réponses: 23
    Dernier message: 15/12/2006, 10h22
  2. Openldap + gestion des droits en java
    Par kabouns dans le forum Administration système
    Réponses: 2
    Dernier message: 09/08/2006, 22h54
  3. Gestion des fenêtres
    Par Galaad dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 11/07/2006, 15h29
  4. [DELPHI6] et gestion des fenêtres windows
    Par Desraux dans le forum API, COM et SDKs
    Réponses: 2
    Dernier message: 27/03/2006, 16h47

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