Results 1 to 4 of 4
  1. #1
    aznboarder is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    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?

    Java 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 Thumbnails Attached Thumbnails extra line in GridLayout-extra-line.jpg  

  2. #2
    trax is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    Default

    I think problem is with ur FileTableContentProvider() ,

  3. #3
    aznboarder is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    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

  4. #4
    trax is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    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

Similar Threads

  1. [SOLVED] Attaching/Including extra package
    By Eranga in forum NetBeans
    Replies: 16
    Last Post: 07-01-2008, 10:25 AM
  2. [SOLVED] File I/O Extra Credit Assignment FTW!
    By Bascotie in forum New To Java
    Replies: 9
    Last Post: 06-10-2008, 08:20 AM
  3. Extra bracket
    By CrazyShells Slam in forum New To Java
    Replies: 5
    Last Post: 05-16-2008, 06:12 AM
  4. SWT GridLayout
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:04 AM
  5. Gridlayout
    By Marty in forum AWT / Swing
    Replies: 2
    Last Post: 05-31-2007, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •