Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2009, 12:28 AM
Member
 
Join Date: Mar 2009
Posts: 8
Rep Power: 0
aznboarder is on a distinguished road
Default extra line in GridLayout
Hello,

I'm trying to put together a GUI with a table and two buttons. I'm using GridLayout and a JFace ApplicationWindow. When I launch my app, there is one extra element in the application that I never add to the Composite parent. I've attached the jpg of the application with the extra line circled. My code is posted below. How is this extra horizontal line being added? Is it added before the createContents method is called? How do I get rid of it?

Code:
	protected Control createContents(Composite parent)
	{
		
		final TableViewer tableViewer = new TableViewer(parent);
		tableViewer.setContentProvider(new FileTableContentProvider());
		
		GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
		//gridData.verticalSpan = 5;
		gridData.heightHint = 200;
		gridData.widthHint = 400;
		
		tableViewer.getTable().setLayoutData(gridData);
		
		Composite rightColumn = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 1;
		rightColumn.setLayout(gridLayout);
		
		Button addDirectoriesButton = new Button(rightColumn, SWT.PUSH);
		addDirectoriesButton.setText("Add Directories");
		
		addDirectoriesButton.addMouseListener(new MouseListener() 
		{
			@Override
			public void mouseDoubleClick(MouseEvent arg0)
			{
			}

			@Override
			public void mouseDown(MouseEvent arg0)
			{
			}

			@Override
			public void mouseUp(MouseEvent mouseEvent)
			{
				DirectoryDialog directoryDialog = new DirectoryDialog(mouseEvent.widget.getDisplay().getActiveShell());
				directoryDialog.setText("Add Files");
				directoryDialog.setFilterPath("c:\\");
				String fileName = directoryDialog.open();
				
				if (fileName != null)
					tableViewer.setInput(new File(fileName));
			}
			
		});
		addDirectoriesButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));

		Button clearDirectoriesButton = new Button(rightColumn, SWT.PUSH);
		clearDirectoriesButton.setText("Clear Directories");
		
		clearDirectoriesButton.addMouseListener(new MouseListener()
		{

			@Override
			public void mouseDoubleClick(MouseEvent arg0)
			{
			}

			@Override
			public void mouseDown(MouseEvent arg0)
			{
			}

			@Override
			public void mouseUp(MouseEvent arg0)
			{
			}
			
		});
		
		return parent;
	}
	
	@Override
	protected Layout getLayout()
	{
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 3;
		return gridLayout;
	}
	
	@Override
	protected Point getInitialSize()
	{
		return new Point(600, 350);
	}
Attached Images:
File Type: jpg extra line.jpg (14.7 KB, 0 views)
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-24-2009, 01:48 PM
Member
 
Join Date: Mar 2009
Posts: 42
Rep Power: 0
trax is on a distinguished road
Default
I think problem is with ur FileTableContentProvider() ,
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-24-2009, 06:45 PM
Member
 
Join Date: Mar 2009
Posts: 8
Rep Power: 0
aznboarder is on a distinguished road
Default
Hello,

Thanks, I actually tried removing different elements yesterday to debug the issue. Even when I removed the entire TableViewer from the GridLayout and just have a label, that line is still there.

I checked the parent object passed to createContents, and when the getChildren method is called, it looks like there's already a Label object that's a child. Is there a way to clear all child elements of a Composite object?

Are you able to reproduce this or is it just me? I'm using 3.4 Ganymede.

-Danny
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 03-25-2009, 06:36 AM
Member
 
Join Date: Mar 2009
Posts: 42
Rep Power: 0
trax is on a distinguished road
Default
Hi ,
you can dispose all the contents of a composite using this code

for(int i =0 ;i< composite.getChildren().length ; i++){
composite.getChildren()[i].dispose();
}

Regards,
Trax
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Attaching/Including extra package Eranga NetBeans 16 07-01-2008 11:25 AM
[SOLVED] File I/O Extra Credit Assignment FTW! Bascotie New To Java 9 06-10-2008 09:20 AM
Extra bracket CrazyShells Slam New To Java 5 05-16-2008 07:12 AM
SWT GridLayout Java Tip Java Tips 0 01-08-2008 10:04 AM
Gridlayout Marty AWT / Swing 2 05-31-2007 12:48 PM


All times are GMT +2. The time now is 07:16 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org