Skip to content

Commit 2897c1f

Browse files
committed
updates
1 parent ae4347f commit 2897c1f

3 files changed

Lines changed: 36 additions & 24 deletions

File tree

de.vogella.swt/src/de/vogella/swt/widgets/CTabFolderExample.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@ public class CTabFolderExample {
1313
public static void main(String[] args) {
1414
Display display = new Display();
1515
Shell shell = new Shell(display);
16-
16+
1717
shell.setLayout(new GridLayout());
18-
CTabFolder folder = new CTabFolder(shell, SWT.NONE);
19-
GridData data = new GridData(GridData.FILL, GridData.BEGINNING, true,
20-
false, 2, 1);
18+
// SWT.BOTTOM to show at the bottom
19+
CTabFolder folder = new CTabFolder(shell, SWT.BOTTOM);
20+
GridData data = new GridData(GridData.FILL, GridData.FILL, true, true,
21+
2, 1);
2122
folder.setLayoutData(data);
2223
CTabItem cTabItem1 = new CTabItem(folder, SWT.NONE);
2324
cTabItem1.setText("Tab1");
2425
CTabItem cTabItem2 = new CTabItem(folder, SWT.NONE);
2526
cTabItem2.setText("Tab2");
2627
CTabItem cTabItem3 = new CTabItem(folder, SWT.NONE);
2728
cTabItem3.setText("Tab3");
28-
29-
Text text = new Text(folder, SWT.BORDER);
29+
30+
Text text = new Text(folder, SWT.BORDER | SWT.MULTI | SWT.WRAP);
3031
text.setText("Hello");
3132
cTabItem1.setControl(text);
32-
33-
shell.pack ();
34-
shell.open ();
33+
34+
shell.setSize(200, 200);
35+
shell.open();
3536

3637
shell.open();
3738
while (!display.isDisposed()) {

de.vogella.swt/src/de/vogella/swt/widgets/DateTimeExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public static void main(String[] args) {
1515
// setup the SWT window
1616
Display display = new Display();
1717
final Shell shell = new Shell(display);
18-
shell.setSize(520, 200);
1918
shell.setLayout(new RowLayout());
2019

2120
// initialize a parent composite with a grid layout manager
@@ -30,7 +29,8 @@ public static void main(String[] args) {
3029
DateTime time = new DateTime(parent, SWT.TIME);
3130
// Date Selection as a drop-down
3231
DateTime dateD = new DateTime(parent, SWT.DATE | SWT.DROP_DOWN);
33-
// show the SWT window
32+
33+
shell.pack();
3434
shell.open();
3535
while (!shell.isDisposed()) {
3636
if (!display.readAndDispatch())

de.vogella.swt/src/de/vogella/swt/widgets/Photo.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package de.vogella.swt.widgets;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import org.eclipse.swt.SWT;
47
import org.eclipse.swt.graphics.Image;
58
import org.eclipse.swt.layout.GridLayout;
@@ -16,7 +19,6 @@ public static void main(String[] args) {
1619
// setup the SWT window
1720
Display display = new Display();
1821
final Shell shell = new Shell(display);
19-
shell.setSize(520, 200);
2022
shell.setLayout(new RowLayout());
2123
shell.setText("Photo Application");
2224

@@ -25,25 +27,34 @@ public static void main(String[] args) {
2527
// 4x columns
2628
Composite parent = new Composite(shell, SWT.NONE);
2729
GridLayout gridLayout = new GridLayout();
28-
gridLayout.numColumns = 4;
30+
gridLayout.numColumns = 7;
2931
parent.setLayout(gridLayout);
3032

31-
// determine the path where the pictures are stored
32-
String path = System.getProperty("user.dir") + "/images/";
33-
// initialize an array with the photograph names
34-
String[] imgNames = new String[] { "lars.png", "andre.png",
35-
"matthias.png", "arne.png" };
33+
// Get the Display default icons
34+
List<Image> imageList = new ArrayList<Image>();
35+
36+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_CANCEL));
37+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_WARNING));
38+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_WORKING));
39+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_QUESTION));
40+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_SEARCH));
41+
imageList
42+
.add(Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
43+
imageList.add(Display.getDefault().getSystemImage(SWT.ICON_ERROR));
3644

37-
// loop over the photo array and establish all listeners
38-
for (int i = 0; i < imgNames.length; i++) {
39-
// labels serve as containers for the images
45+
// Alternative load images via
46+
// Image img = new Image(display, path + imgNames[i]);
47+
// to get a path
48+
// String path = System.getProperty("user.dir") + "/images/";
49+
for (Image image : imageList) {
4050
Label label = new Label(parent, SWT.NONE);
41-
Image img = new Image(display, path + imgNames[i]);
42-
label.setImage(img);
51+
label.setImage(image);
4352
}
44-
4553
// show the SWT window
54+
55+
shell.pack();
4656
shell.open();
57+
4758
while (!shell.isDisposed()) {
4859
if (!display.readAndDispatch())
4960
display.sleep();

0 commit comments

Comments
 (0)