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

SWT/JFace Java Discussion :

[SWT] problème de layout (bis)


Sujet :

SWT/JFace Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut [SWT] problème de layout (bis)
    Hello,

    J'ai à nouveau un problème de layout qui apparait, le label properties n est pas aligné a gauche comme il devrait l'être

    voici mon code

    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
     
    		Composite propertiesContainer = new Composite(body, SWT.NONE);
    		gridLayout = new GridLayout();
    		gridLayout.numColumns = 2;
    		propertiesContainer.setLayout(gridLayout);
    		gridData = new GridData(GridData.BEGINNING);
    		gridData.horizontalSpan = 1;
    		gridData.verticalSpan = 10;
    		gridData.heightHint = 100;
    		//gridData.widthHint = 200;
    		propertiesContainer.setLayoutData(gridData);
    		Label propertiesLabel = new Label(propertiesContainer,SWT.NONE);
    		propertiesLabel.setText("Properties:");
    		gridData = new GridData(GridData.BEGINNING);
    		gridData.verticalSpan = 1;
    		propertiesLabel.setLayoutData(gridData);
    		gridData = new GridData(GridData.FILL_BOTH);
    		gridData.verticalSpan = 20;
     
    		localizableEditor = new LocalizableEditor(propertiesContainer, gridData);
    et le résultat en screenshot dans la pièce jointe

  2. #2
    Membre chevronné
    Profil pro
    Étudiant
    Inscrit en
    Septembre 2007
    Messages
    340
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2007
    Messages : 340
    Par défaut
    Je pense que c'est à cause de tes "verticalSpan = 10" ou "verticalSpan = 20" alors que ton GridLayout ne contient que 2 colones.

  3. #3
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    J ai corrigé le problème d'alignement de ma partie properties mais maintenant j aimerais aligner les label avec le sommet de la liste et des tables

    voici le code complet de ma création des composants graphiques

    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
     
    	/**
             * Create the dialog area and place correctly the user interfaces widgets
             */
    	@Override
    	protected Control createDialogArea(Composite parent) {
    	    Composite body = (Composite)super.createDialogArea(parent);
    	    // The grid layout
    	    GridLayout gridLayout = new GridLayout();
    	    gridLayout.numColumns = 2;
     
    	    body.setLayout(gridLayout);
    	    GridData gridData = new GridData();
    		gridData.heightHint = 350;
    		gridData.minimumWidth = 400;
     
    		body.setLayoutData(gridData);
    		// Event label
    		Label eventLbl = new Label(body, SWT.LEFT);
    		eventLbl.setText("Event:");
     
    		// Events combo box
    		eventCbx = new Combo(body, SWT.NULL);
    		fillEventTypesList(widget);
    		gridData = new GridData(GridData.BEGINNING);
    		gridData.widthHint = 115;
    		eventCbx.setLayoutData(gridData);
     
    		eventCbx.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				int index = ((Combo) e.getSource()).getSelectionIndex();
    				String eventName = eventCbx.getItem(index);
    				event = makeWidgetEvent(eventName);
    				localizableEditor.getTableViewer().getTable().removeAll();
    				if (methodName.equals(CREATE)) {
    					addNewEventType(event);
    				}
    				eventType = findEventType(eventName, widget.getType());
    				currentEventType = eventType;
    				paramsTbl.removeAll();
     
    				fillFunctionsList(widget, eventType, event, false);			
    			}
    		});
    		// Functions label
    		Label functionsLbl = new Label(body, SWT.LEFT);
    		functionsLbl.setText("Functions:");
    		gridData = new GridData(GridData.BEGINNING);
     
    		functionsLbl.setLayoutData(gridData);
    		fctList = new List(body,SWT.BORDER | SWT.SINGLE
    				| SWT.V_SCROLL);
    		gridData = new GridData(GridData.END);
    		gridData.verticalSpan = 1;
    		gridData.horizontalSpan = 1;
    		gridData.heightHint = 120;
    		gridData.widthHint = 120;
    		//Functions list		
    		fctList.setLayoutData(gridData);
    		fctList.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				int index = eventCbx.getSelectionIndex();
    				eventName = eventCbx.getItem(index);
    				int indexOfFunc = fctList.getSelectionIndex();
    				funcName = fctList.getItem(indexOfFunc);
    				event = makeWidgetEvent(eventName,funcName);
    				prepareWidgetEventModification(funcName,eventName);				
    			}
    		});
    		if (selectedEventName != null) {
    			int idx = eventCbx.indexOf(selectedEventName);
    			eventCbx.select(idx);
     
    			currentEventType = findEventType(eventCbx.getItem(idx), widget.getType());			
    			event = widget.getEvents().get(getIndexOfEvent(selectedEventName));
    			fillFunctionsList(widget,currentEventType, event, false);
    		}else {
    			fillFunctionsList(widget, eventType, event, false);
    		}
     
    		// Parameters label
    		Label paramsLabel = new Label(body,SWT.NONE);
    		paramsLabel.setText("Parameters:");
    		gridData = new GridData(GridData.FILL_HORIZONTAL);
    		//gridData.verticalSpan = 28;
     
    		paramsLabel.setLayoutData(gridData);
    		// Parameters table
        	paramsTbl = new Table(body, SWT.SINGLE);
    		gridData = new GridData(GridData.FILL_BOTH);
    		gridData.horizontalSpan = 1;
    		//gridData.verticalSpan = 20;
    		paramsTbl.setLayoutData(gridData);
    		paramsTbl.setHeaderVisible(true);
    		addColumn(paramsTbl, "Parameter", 100);
    		addColumn(paramsTbl, "Value", 200);
     
     
    		final TableEditor paramsTblEditor = new TableEditor(paramsTbl);
    		// The editor must have the same size as the cell and must not be any
    		// smaller than 50 pixels.
    		paramsTblEditor.horizontalAlignment = SWT.LEFT;
    		paramsTblEditor.grabHorizontal = true;
    		paramsTblEditor.minimumWidth = 50;
    		paramsTbl.addListener(SWT.MouseDown, new Listener() {
    			public void handleEvent(org.eclipse.swt.widgets.Event event) {
    				int nbColumns = paramsTbl.getColumnCount();
    				Rectangle clientArea = paramsTbl.getClientArea();
    				Point pt = new Point(event.x, event.y);
    				int index = paramsTbl.getTopIndex();
    				while (index < paramsTbl.getItemCount()) {
    					boolean visible = false;
    					TableItem item = paramsTbl.getItem(index);
    					for (int cx = 0; cx < nbColumns; cx++) {
    						Rectangle rect = item.getBounds(cx);
    						if (rect.contains(pt)) {
    							installCellEditor(paramsTblEditor, item, index, cx);
    						}
    						if (!visible && rect.intersects(clientArea)) {
    							visible = true;
    						}
    					}
    					if (!visible)
    						return;
    					index++;
    				}
    			}
    		});
     
    		Label propertiesLabel = new Label(body,SWT.NONE);
    		propertiesLabel.setText("Properties:");
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
     
    		propertiesLabel.setLayoutData(gridData);
    		gridData = new GridData(GridData.BEGINNING);
     
    		localizableEditor = new LocalizableEditor(body, gridData);
     
    	    return body;
    	}
    et voici le résultat que j obtiens (en pièces jointes)

  4. #4
    Membre habitué
    Inscrit en
    Février 2007
    Messages
    12
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 12
    Par défaut
    As tu essayé de mettre un gridData(SWT.BEGINNING, SWT.BEGINNING, false, false) sur tes labels?

Discussions similaires

  1. [SWT] problème de layout
    Par *alexandre* dans le forum SWT/JFace
    Réponses: 1
    Dernier message: 27/05/2008, 08h40
  2. Problème avec layout en SWT
    Par talkhor dans le forum Agents de placement/Fenêtres
    Réponses: 3
    Dernier message: 22/08/2007, 17h25
  3. [SWT] Problème de GridLayout
    Par otsgd dans le forum SWT/JFace
    Réponses: 3
    Dernier message: 06/06/2006, 14h37
  4. [SWT] Problème avec la transparence des PNG
    Par sirjuh dans le forum SWT/JFace
    Réponses: 1
    Dernier message: 02/08/2004, 08h07
  5. [SWT] Problème de paramètre GridData
    Par yolepro dans le forum SWT/JFace
    Réponses: 4
    Dernier message: 06/12/2002, 10h37

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