VE error when I use a FormAttachment [message #606083] |
Fri, 25 March 2005 18:19 |
Eclipse User |
|
|
|
Originally posted by: chris.chrisbenson.com
I get the following error message when I try to use a FormAttachment in
the Visual Editor:
Error trying to set new file into editor.
Reason: java.lang.NullPointerException
This is my code. If I comment out the lines like "data.top = new
FormAttachment(0, 5);" then it renders in the visual editor part. If I
uncomment the lines the error returns. Can anyone help me with this?
Thanks.
/*
* Created on Mar 16, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.chrisbenson.data.developer;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
//import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Composite;
/**
* @author Chris
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GuiMain
{
private org.eclipse.swt.widgets.Shell shell = null; //
@jve:decl-index=0:visual-constraint="40,54"
private Button newButton = null;
private Text newDatasourceText = null;
public static void main(String[] args)
{
/* Before this is run, be sure to set up the following in the launch
configuration
* (Arguments->VM Arguments) for the correct SWT library path.
* The following is a windows example:
*
-Djava.library.path=" installation_directory\plugins\org.eclipse.swt.win32_3.0.0\o s\win32\x86 "
*/
org.eclipse.swt.widgets.Display display =
org.eclipse.swt.widgets.Display.getDefault();
GuiMain thisClass = new GuiMain();
thisClass.createShell();
thisClass.shell.pack();
thisClass.shell.open();
while (!thisClass.shell.isDisposed())
{
if (!display.readAndDispatch()) display.sleep ();
}
display.dispose();
}
/**
* This method initializes shell
*/
private void createShell()
{
shell = new org.eclipse.swt.widgets.Shell();
shell.setSize(new org.eclipse.swt.graphics.Point(800,600));
shell.setText("Data Developer");
FormLayout layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
layout.spacing = 5;
shell.setLayout(layout);
newButton = new Button(shell, SWT.PUSH);
newButton.setText("New");
newDatasourceText = new Text(shell, SWT.NONE);
newDatasourceText.setBounds(new
org.eclipse.swt.graphics.Rectangle(50,50,150,25));
FormData data = new FormData();
data.height = 50;
data.width = 50;
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(0, 5);
data.bottom = new FormAttachment(50, -5);
data.right = new FormAttachment(50, -5);
newButton.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(newButton);
data.bottom = new FormAttachment(50, -5);
data.right = new FormAttachment(50, -5);
newDatasourceText.setLayoutData(data);
newButton.addSelectionListener(new
org.eclipse.swt.events.SelectionAdapter()
{
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
org.eclipse.swt.widgets.DirectoryDialog dirdlg = new
org.eclipse.swt.widgets.DirectoryDialog(shell);
String selectedDirectory = dirdlg.open();
//String newDatasourceText = "";
}
}
);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02659 seconds