Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » creating tab using button but get error NullPointerException and visual editor can't works correctly
creating tab using button but get error NullPointerException and visual editor can't works correctly [message #134845] Sun, 14 January 2007 07:19
Eclipse UserFriend
Originally posted by: kboonchai.hotmail.com

I tried to create tabs using button in visual editor, but when i reopen the
file using visual editor, there is a msg shown as NullPointerException and i
try to put a button in the visual editor but it din't works after it.
I did a few trys and the error gone when i tried to put the creating tabs
function into the widgetselected function and reopen the file.

Any idea to fix this?

Below is my code:

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.graphics.Rectangle;
public class test {

private Shell sShell = null; //
@jve:decl-index=0:visual-constraint="58,21"
private Button bNewTab = null;
private CTabFolder cTabFolder = null;
private Text textArea = null;

public static void main(String [] args) {
Display display = Display.getDefault();
test thisclass = new test();
thisclass.createSShell();
thisclass.sShell.open();
while(!thisclass.sShell.isDisposed()){
if(!display.readAndDispatch()){
display.sleep();
}
}
}

private void createSShell() {
sShell = new Shell();
sShell.setLayout(null);
sShell.setSize(new Point(387, 159));
bNewTab = new Button(sShell, SWT.NONE);
bNewTab.setBounds(new Rectangle(5, 5, 70, 23));
bNewTab.setText("New Tab");
bNewTab.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
{
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
createTab();
}
});
createCTabFolder();
}

private void createCTabFolder() {
cTabFolder = new CTabFolder(sShell, SWT.NONE);
cTabFolder.setBounds(new Rectangle(5, 33, 370, 86));
}

private void createTab() {
Integer tabCounter;
CTabItem item = new CTabItem(cTabFolder, SWT.NONE);
tabCounter = cTabFolder.getItemCount();
item.setText(tabCounter.toString());
textArea = new Text(cTabFolder, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
item.setControl(textArea);
cTabFolder.setSelection(cTabFolder.getItemCount()-1);
}
}


  • Attachment: test.java
    (Size: 1.79KB, Downloaded 277 times)
Previous Topic:Extending VE Code generation to generate XML
Next Topic:creating tab using button but get error NullPointerException and visual editor can't works correctly
Goto Forum:
  


Current Time: Sat Jul 27 13:25:15 GMT 2024

Powered by FUDForum. Page generated in 0.05084 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top