KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > fenyo > gnetwatch > GUI > DialogAbout


1
2 /*
3  * GNetWatch
4  * Copyright 2006, 2007 Alexandre Fenyo
5  * gnetwatch@fenyo.net
6  *
7  * This file is part of GNetWatch.
8  *
9  * GNetWatch is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * GNetWatch is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GNetWatch; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  */

23
24 package net.fenyo.gnetwatch.GUI;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.eclipse.swt.*;
30 import org.eclipse.swt.widgets.*;
31 import org.eclipse.swt.layout.*;
32 import org.eclipse.swt.custom.*;
33 import org.eclipse.swt.events.*;
34 import org.eclipse.swt.graphics.*;
35 import org.eclipse.swt.browser.*;
36
37 /**
38  * This class displays the "about" dialog.
39  * @author Alexandre Fenyo
40  * @version $Id: DialogAbout.java,v 1.6 2007/03/03 00:38:19 fenyo Exp $
41  */

42
43 public class DialogAbout extends Dialog {
44   private static Log log = LogFactory.getLog(DialogAbout.class);
45
46   private GridLayout layout = null;
47   private Composite groups_composite = null;
48   private Composite bottom_composite = null;
49   private RowLayout groups_composite_layout = null;
50   private RowLayout bottom_composite_layout = null;
51   private GridData groups_composite_grid_data = null;
52   private Label label_image = null;
53   private GUI gui;
54
55   /**
56    * Constructor.
57    * @param gui current GUI instance.
58    * @param parent parent shell.
59    */

60   public DialogAbout(final GUI gui, final Shell parent) {
61     super(parent, 0);
62     this.gui = gui;
63   }
64
65   /**
66    * Displays the dialog.
67    * @param none.
68    * @return void.
69    */

70   public void open() {
71     final Shell parent = getParent();
72     final Display display = parent.getDisplay();
73     final Shell shell = new Shell(parent, SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
74     shell.setText("GNetWatch - About");
75
76     // Your code goes here (widget creation, set result, etc).
77
// Composite for groups at left
78
layout = new GridLayout();
79     layout.numColumns = 1;
80     layout.marginHeight = 2;
81     layout.marginWidth = 2;
82     layout.verticalSpacing = 1;
83     shell.setLayout(layout);
84
85     groups_composite = new Composite(shell, SWT.FLAT);
86     groups_composite_layout = new RowLayout(SWT.VERTICAL);
87     groups_composite_layout.fill = true;
88     groups_composite_layout.marginTop = 0;
89     groups_composite_layout.marginBottom = 0;
90     groups_composite.setLayout(groups_composite_layout);
91     groups_composite_grid_data = new GridData(GridData.FILL_VERTICAL);
92     groups_composite.setLayoutData(groups_composite_grid_data);
93
94     // Group for network parameters
95

96     label_image = new Label(groups_composite, SWT.SHADOW_ETCHED_IN | SWT.BORDER);
97     label_image.setText("Network parameters");
98     label_image.setImage(new Image(display, "pictures/about.png"));
99
100     // bottom buttons
101

102     bottom_composite = new Composite(shell, SWT.FLAT);
103     bottom_composite_layout = new RowLayout();
104     bottom_composite_layout.fill = true;
105     bottom_composite_layout.marginTop = 0;
106     bottom_composite_layout.marginBottom = 0;
107     bottom_composite_layout.wrap = false;
108     bottom_composite_layout.pack = false;
109     bottom_composite_layout.justify = true;
110     bottom_composite_layout.type = SWT.HORIZONTAL;
111     bottom_composite_layout.marginLeft = 5;
112     bottom_composite_layout.marginTop = 5;
113     bottom_composite_layout.marginRight = 5;
114     bottom_composite_layout.marginBottom = 5;
115     bottom_composite_layout.spacing = 0;
116     bottom_composite.setLayout(bottom_composite_layout);
117     final GridData bottom_composite_grid_data = new GridData(GridData.FILL_HORIZONTAL);
118     bottom_composite.setLayoutData(bottom_composite_grid_data);
119
120     final Button button_ok = new Button(bottom_composite, SWT.PUSH);
121     button_ok.setText(gui.getConfig().getString("license"));
122
123     button_ok.addSelectionListener(new SelectionListener() {
124       public void widgetDefaultSelected(SelectionEvent e) {
125         shell.dispose();
126       }
127
128       public void widgetSelected(SelectionEvent e) {
129         widgetDefaultSelected(e);
130       }
131     });
132
133     shell.pack(true);
134     shell.open();
135     while (!shell.isDisposed())
136       if (!display.readAndDispatch()) display.sleep();
137   }
138 }
139
Popular Tags