Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
swt-jface:layout 2008/05/21 23:14 | swt-jface:layout 2020/01/22 20:59 aktuell | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | [[swt-jface:swt-jface|Java - SWT/JFace]]\\ | ||
====== Layout (SWT) ====== | ====== Layout (SWT) ====== | ||
Mächte man ein Layout erzeugen, welches je nach Fensterbreite die Elemente nebeneinander oder untereinander anordnet, so ist die richtige Wahl das | Mächte man ein Layout erzeugen, welches je nach Fensterbreite die Elemente nebeneinander oder untereinander anordnet, so ist die richtige Wahl das | ||
Zeile 5: | Zeile 6: | ||
Möchte man nachträglich das Layout neu berechnen, so genügt ein Aufruf der Methode\\ | Möchte man nachträglich das Layout neu berechnen, so genügt ein Aufruf der Methode\\ | ||
//pack(true)// | //pack(true)// | ||
+ | \\ | ||
+ | \\ | ||
+ | <html> | ||
+ | <script type="text/javascript"><!-- | ||
+ | google_ad_client="pub-9681858985507948"; | ||
+ | google_ad_width = 468; | ||
+ | google_ad_height = 60; | ||
+ | google_ad_format = "468x60_as"; | ||
+ | google_ad_type = "text"; | ||
+ | google_ad_channel = ""; | ||
+ | google_color_border = "cccccc"; | ||
+ | google_color_bg = "FFFFFF"; | ||
+ | google_color_link = "1d2d8c"; | ||
+ | google_color_text = "000000"; | ||
+ | google_color_url = "1d2d8c"; | ||
+ | //--> | ||
+ | </script> | ||
+ | <script type="text/javascript" | ||
+ | src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
+ | </script> | ||
+ | </html> | ||
+ | \\ | ||
+ | \\ | ||
+ | Beispiel für ein Layout:\\ | ||
+ | {{:swt-jface:layout.png|}}\\ | ||
+ | \\ | ||
+ | ...und der dazugehörige Code: | ||
+ | <code java> | ||
+ | parent.setLayout(new GridLayout(2, false)); | ||
+ | GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, false); | ||
+ | gd.horizontalAlignment = GridData.FILL; | ||
+ | gd.grabExcessHorizontalSpace = true; | ||
+ | |||
+ | Label labelName = new Label(parent, SWT.NONE); | ||
+ | labelName.setText("Name:"); | ||
+ | Text textName = new Text(parent, SWT.SINGLE | SWT.BORDER); | ||
+ | textName.setLayoutData(gd); | ||
+ | |||
+ | Label labelStreet = new Label(parent, SWT.NONE); | ||
+ | labelStreet.setText("Straße:"); | ||
+ | Text textStreet = new Text(parent, SWT.SINGLE | SWT.BORDER); | ||
+ | textStreet.setLayoutData(gd); | ||
+ | |||
+ | Label labelZipCity = new Label(parent, SWT.NONE); | ||
+ | labelZipCity.setText("Plz/Ort:"); | ||
+ | Composite composite = new Composite(parent, SWT.NONE); | ||
+ | |||
+ | composite.setLayout(new GridLayout(2, false)); | ||
+ | composite.setLayoutData(gd); | ||
+ | UIControlsFactory.createText(composite); | ||
+ | Text textCity = new Text(parent, SWT.SINGLE | SWT.BORDER); | ||
+ | textCity.setLayoutData(gd); | ||
+ | |||
+ | Label labelLand = new Label(parent, SWT.NONE); | ||
+ | labelLand .setText("Land:"); | ||
+ | CCombo cComboLand = new CCombo(parent, SWT.BORDER | SWT.READ_ONLY); | ||
+ | cComboLand.setLayoutData(gd); | ||
+ | </code> | ||
+ | |||