Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Could any find the error in this piece of code
Could any find the error in this piece of code [message #466362] |
Mon, 09 January 2006 13:37 |
Neel Messages: 29 Registered: July 2009 |
Junior Member |
|
|
Hi,
In this piece of code, I tried to create a table inside a Group,but this
table is not getting visible when I run it.
Please could any one say wats wrong in this code
// Code Start
package screens;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class CategorySelectionScr extends Shell {
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
CategorySelectionScr shell = new CategorySelectionScr(display,
SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell
* @param display
* @param style
*/
public CategorySelectionScr(Display display, int style) {
super(display, style);
createContents();
}
/**
* Create contents of the window
*/
protected void createContents() {
setText("SWT Application");
setSize(727, 521);
final Composite composite = new Composite(this, SWT.NONE);
composite.setBounds(0, 0, 716, 483);
final Composite composite_1 = new Composite(composite, SWT.NONE);
composite_1.setBounds(5, 25, 214, 455);
final Group selectCategoryGroup = new Group(composite_1, SWT.NONE);
selectCategoryGroup.setText("Select Category");
selectCategoryGroup.setBounds(5, 5, 205, 155);
final CLabel lblcategory = new CLabel(selectCategoryGroup, SWT.NONE);
lblcategory.setAlignment(SWT.RIGHT);
lblcategory.setText("Category");
lblcategory.setBounds(10, 20, 60, 20);
final StyledText styledText = new StyledText(selectCategoryGroup,
SWT.BORDER);
styledText.setBounds(80, 21, 115, 19);
final Button searchButton = new Button(selectCategoryGroup, SWT.NONE);
searchButton.setText("Search");
searchButton.setBounds(110, 55, 90, 30);
final CTabFolder tabFolder = new CTabFolder(composite, SWT.NONE);
tabFolder.setMRUVisible(true);
tabFolder.setBounds(223, 25, 490, 453);
final CTabItem categoryListTabItem = new CTabItem(tabFolder, SWT.NONE);
categoryListTabItem.setText("Category List");
final Group categoryListGroup = new Group(tabFolder, SWT.NONE);
categoryListGroup.setText("Category List");
categoryListTabItem.setControl(categoryListGroup);
final Table table = new Table(categoryListGroup, SWT.BORDER | SWT.RADIO);
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(10, 20, 459, 240);
final TableColumn tc1 = new TableColumn(table, SWT.LEFT);
final TableColumn tc2 = new TableColumn(table, SWT.CENTER);
final TableColumn tc3 = new TableColumn(table, SWT.CENTER);
// final TableColumn tc4 = new TableColumn(table, SWT.CENTER);
tc1.setText("Category");
tc2.setText("Description");
tc3.setText("Slot");
// tc4.setText("Slot");
tc1.setWidth(40);
tc2.setWidth(70);
tc3.setWidth(80);
// tc4.setWidth(70);
final TableItem item1 = new TableItem(table, SWT.NONE);
item1.setText(new String[] { "Radio", "Radio with FM", "Radio" });
final TableItem item2 = new TableItem(table, SWT.NONE);
item2.setText(new String[] { "Fahrersitz", "Fahrersitz", "Fahrersitz"
});
}
//@Override
protected void checkSubclass() {
}
}
// Code Ends
Thanks and Regards,
Neel
|
|
|
Re: Could any find the error in this piece of code [message #466363 is a reply to message #466362] |
Mon, 09 January 2006 14:10 |
Eclipse User |
|
|
|
Originally posted by: f.fankhauser.gmx.at
Hi Neel,
class Shell cannot be extended.
From the swt docs for Shell: IMPORTANT: This class is not intended to be
subclassed.
Florian
Neel schrieb:
> Hi,
>
> In this piece of code, I tried to create a table inside a Group,but
> this table is not getting visible when I run it.
>
> Please could any one say wats wrong in this code
>
>
> // Code Start
> package screens;
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.CLabel;
> import org.eclipse.swt.custom.CTabFolder;
> import org.eclipse.swt.custom.CTabItem;
> import org.eclipse.swt.custom.StyledText;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TableItem;
>
> public class CategorySelectionScr extends Shell {
>
>
> /**
> * Launch the application
> * @param args
> */
> public static void main(String args[]) {
> try {
> Display display = Display.getDefault();
> CategorySelectionScr shell = new
> CategorySelectionScr(display,
> SWT.SHELL_TRIM);
> shell.open();
> shell.layout();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> /**
> * Create the shell
> * @param display
> * @param style
> */
> public CategorySelectionScr(Display display, int style) {
> super(display, style);
> createContents();
> }
>
> /**
> * Create contents of the window
> */
> protected void createContents() {
> setText("SWT Application");
> setSize(727, 521);
>
> final Composite composite = new Composite(this, SWT.NONE);
> composite.setBounds(0, 0, 716, 483);
>
> final Composite composite_1 = new Composite(composite, SWT.NONE);
> composite_1.setBounds(5, 25, 214, 455);
>
> final Group selectCategoryGroup = new Group(composite_1,
> SWT.NONE);
> selectCategoryGroup.setText("Select Category");
> selectCategoryGroup.setBounds(5, 5, 205, 155);
>
> final CLabel lblcategory = new CLabel(selectCategoryGroup,
> SWT.NONE);
> lblcategory.setAlignment(SWT.RIGHT);
> lblcategory.setText("Category");
> lblcategory.setBounds(10, 20, 60, 20);
>
> final StyledText styledText = new
> StyledText(selectCategoryGroup, SWT.BORDER);
> styledText.setBounds(80, 21, 115, 19);
>
> final Button searchButton = new Button(selectCategoryGroup,
> SWT.NONE);
> searchButton.setText("Search");
> searchButton.setBounds(110, 55, 90, 30);
>
> final CTabFolder tabFolder = new CTabFolder(composite, SWT.NONE);
> tabFolder.setMRUVisible(true);
> tabFolder.setBounds(223, 25, 490, 453);
>
> final CTabItem categoryListTabItem = new CTabItem(tabFolder,
> SWT.NONE);
> categoryListTabItem.setText("Category List");
>
> final Group categoryListGroup = new Group(tabFolder, SWT.NONE);
> categoryListGroup.setText("Category List");
> categoryListTabItem.setControl(categoryListGroup);
>
> final Table table = new Table(categoryListGroup, SWT.BORDER |
> SWT.RADIO);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> table.setBounds(10, 20, 459, 240);
> final TableColumn tc1 = new TableColumn(table, SWT.LEFT);
> final TableColumn tc2 = new TableColumn(table, SWT.CENTER);
> final TableColumn tc3 = new TableColumn(table, SWT.CENTER);
> // final TableColumn tc4 = new TableColumn(table, SWT.CENTER);
> tc1.setText("Category");
> tc2.setText("Description");
> tc3.setText("Slot");
> // tc4.setText("Slot");
> tc1.setWidth(40);
> tc2.setWidth(70);
> tc3.setWidth(80);
> // tc4.setWidth(70);
> final TableItem item1 = new TableItem(table, SWT.NONE);
> item1.setText(new String[] { "Radio", "Radio with FM", "Radio"
> });
> final TableItem item2 = new TableItem(table, SWT.NONE);
> item2.setText(new String[] { "Fahrersitz", "Fahrersitz",
> "Fahrersitz" });
>
>
>
>
>
> }
>
> //@Override
> protected void checkSubclass() {
> }
>
> }
>
> // Code Ends
>
>
> Thanks and Regards,
> Neel
>
>
>
|
|
| |
Re: Could any find the error in this piece of code [message #466383 is a reply to message #466362] |
Mon, 09 January 2006 22:12 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
Call tabFolder.setBounds(223, 25, 490, 453) after calling
categoryListTabItem.setControl(categoryListGroup).
"Neel" <neelakantan_k@infosys.com> wrote in message
news:bfd2ce5b03bef267e1217cc74faae8ff$1@www.eclipse.org...
> Hi,
>
> In this piece of code, I tried to create a table inside a Group,but this
> table is not getting visible when I run it.
>
> Please could any one say wats wrong in this code
>
>
> // Code Start
> package screens;
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.CLabel;
> import org.eclipse.swt.custom.CTabFolder;
> import org.eclipse.swt.custom.CTabItem;
> import org.eclipse.swt.custom.StyledText;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TableItem;
>
> public class CategorySelectionScr extends Shell {
>
>
> /**
> * Launch the application
> * @param args
> */
> public static void main(String args[]) {
> try {
> Display display = Display.getDefault();
> CategorySelectionScr shell = new CategorySelectionScr(display,
> SWT.SHELL_TRIM);
> shell.open();
> shell.layout();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> /**
> * Create the shell
> * @param display
> * @param style
> */
> public CategorySelectionScr(Display display, int style) {
> super(display, style);
> createContents();
> }
>
> /**
> * Create contents of the window
> */
> protected void createContents() {
> setText("SWT Application");
> setSize(727, 521);
>
> final Composite composite = new Composite(this, SWT.NONE);
> composite.setBounds(0, 0, 716, 483);
>
> final Composite composite_1 = new Composite(composite, SWT.NONE);
> composite_1.setBounds(5, 25, 214, 455);
>
> final Group selectCategoryGroup = new Group(composite_1, SWT.NONE);
> selectCategoryGroup.setText("Select Category");
> selectCategoryGroup.setBounds(5, 5, 205, 155);
>
> final CLabel lblcategory = new CLabel(selectCategoryGroup, SWT.NONE);
> lblcategory.setAlignment(SWT.RIGHT);
> lblcategory.setText("Category");
> lblcategory.setBounds(10, 20, 60, 20);
>
> final StyledText styledText = new StyledText(selectCategoryGroup,
> SWT.BORDER);
> styledText.setBounds(80, 21, 115, 19);
>
> final Button searchButton = new Button(selectCategoryGroup, SWT.NONE);
> searchButton.setText("Search");
> searchButton.setBounds(110, 55, 90, 30);
>
> final CTabFolder tabFolder = new CTabFolder(composite, SWT.NONE);
> tabFolder.setMRUVisible(true);
> tabFolder.setBounds(223, 25, 490, 453);
>
> final CTabItem categoryListTabItem = new CTabItem(tabFolder, SWT.NONE);
> categoryListTabItem.setText("Category List");
>
> final Group categoryListGroup = new Group(tabFolder, SWT.NONE);
> categoryListGroup.setText("Category List");
> categoryListTabItem.setControl(categoryListGroup);
>
> final Table table = new Table(categoryListGroup, SWT.BORDER | SWT.RADIO);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> table.setBounds(10, 20, 459, 240);
> final TableColumn tc1 = new TableColumn(table, SWT.LEFT);
> final TableColumn tc2 = new TableColumn(table, SWT.CENTER);
> final TableColumn tc3 = new TableColumn(table, SWT.CENTER);
> // final TableColumn tc4 = new TableColumn(table, SWT.CENTER);
> tc1.setText("Category");
> tc2.setText("Description");
> tc3.setText("Slot");
> // tc4.setText("Slot");
> tc1.setWidth(40);
> tc2.setWidth(70);
> tc3.setWidth(80);
> // tc4.setWidth(70);
> final TableItem item1 = new TableItem(table, SWT.NONE);
> item1.setText(new String[] { "Radio", "Radio with FM", "Radio" });
> final TableItem item2 = new TableItem(table, SWT.NONE);
> item2.setText(new String[] { "Fahrersitz", "Fahrersitz",
> "Fahrersitz" });
>
>
>
>
>
> }
>
> //@Override
> protected void checkSubclass() {
> }
>
> }
>
> // Code Ends
>
>
> Thanks and Regards,
> Neel
>
>
>
|
|
|
Goto Forum:
Current Time: Sat Dec 07 15:46:07 GMT 2024
Powered by FUDForum. Page generated in 0.03278 seconds
|