Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Help,how to solve this java.lang.NullPointerException  () 1 Vote
Help,how to solve this java.lang.NullPointerException [message #134722] Fri, 12 January 2007 05:41 Go to next message
Eclipse UserFriend
Originally posted by: nick_carterk.yahoo.com

i was trying to write multitabs text editor with VE, but when i reopen the file, a msg shown with java.lang.NullPointerException, i tested few times and i still can't solve this problem. Can anyone lend me a help pls?

below is my codes

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
public class GUI {

private Shell sShell = null;
private CTabFolder cTabFolder = null;
private Integer tabCounter = 0;
private Button bOpen = null;
private Text textArea = null;

/**
* This method initializes cTabFolder
*
*/
public static void main(String [] args) {
Display display = Display.getDefault();
GUI thisClass = new GUI();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

private void createSShell() {
sShell = new Shell();
sShell.setLayout(null);
createCTabFolder();
sShell.setSize(new Point(498, 204));
bOpen = new Button(sShell, SWT.NONE);
bOpen.setBounds(new Rectangle(19, 121, 46, 34));
bOpen.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
addtab();
}
});
}

private void createCTabFolder() {
cTabFolder = new CTabFolder(sShell, SWT.NONE);
cTabFolder.setBounds(new Rectangle(19, 7, 455, 105));
}

private void addtab() {
CTabItem filetab = new CTabItem(cTabFolder, SWT.NONE);
filetab.setText(tabCounter.toString());
tabCounter++;
textArea = new Text(cTabFolder, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
filetab.setControl(textArea);
FileDialog fileDialog = new FileDialog(sShell, SWT.OPEN);
fileDialog.setText("Open");
fileDialog.setFilterPath("C:/");
String[] filterExt = { "*.txt", "*.*" };
fileDialog.setFilterExtensions(filterExt);
String selected = fileDialog.open();
if (selected == null)
return;
// code here to open the file and display
FileReader file = null;
try {
file = new FileReader(selected);
} catch (FileNotFoundException e) {
MessageBox messageBox = new MessageBox(sShell, SWT.ICON_ERROR | SWT.OK);
messageBox.setMessage("Could not open file.");
messageBox.setText("Error");
messageBox.open();
return;
}
BufferedReader fileInput = new BufferedReader(file);
String text = null;
StringBuffer sb = new StringBuffer();
try {
do {
if (text != null)
sb.append(text);
} while ((text = fileInput.readLine()) != null);
} catch (IOException e1) {
MessageBox messageBox = new MessageBox(sShell, SWT.ICON_ERROR | SWT.OK);
messageBox.setMessage("Could not write to file.");
messageBox.setText("Error");
messageBox.open();
return;
}
textArea.setText(sb.toString());
cTabFolder.setFocus();
}

}
Re: Help,how to solve this java.lang.NullPointerException [message #134781 is a reply to message #134722] Fri, 12 January 2007 20:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Try clearing the cache first. That often cleans up the problem. If it
doesn't then I don't know what is wrong.

1) Open a VE, then close it and all other VE's.
2) Do Project->Clean all... and wait for build to complete.
3) Open a VE. Cache is now cleared.


--
Thanks,
Rich Kulp
Re: Help,how to solve this java.lang.NullPointerException [message #536205 is a reply to message #134722] Thu, 27 May 2010 11:33 Go to previous messageGo to next message
Arun  is currently offline Arun Friend
Messages: 2
Registered: May 2010
Junior Member
I also having same problem with eclipse-ve.. when i double click on my class file it shows "error for eclipse" java.lang.NullPointerException...


please i need help... this stops my work... i need help...

if anybody have solution for this problem let me know.... plz...


thanks....
Re: Help,how to solve this java.lang.NullPointerException [message #614986 is a reply to message #134722] Fri, 12 January 2007 20:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Try clearing the cache first. That often cleans up the problem. If it
doesn't then I don't know what is wrong.

1) Open a VE, then close it and all other VE's.
2) Do Project->Clean all... and wait for build to complete.
3) Open a VE. Cache is now cleared.


--
Thanks,
Rich Kulp
Re: Help,how to solve this java.lang.NullPointerException [message #618387 is a reply to message #134722] Thu, 27 May 2010 11:33 Go to previous message
Arun  is currently offline Arun Friend
Messages: 2
Registered: May 2010
Junior Member
I also having same problem with eclipse-ve.. when i double click on my class file it shows "error for eclipse" java.lang.NullPointerException...


please i need help... this stops my work... i need help...

if anybody have solution for this problem let me know.... plz...


thanks....
Previous Topic:Re: VE plugin problem
Next Topic:Re: Installing visual editor
Goto Forum:
  


Current Time: Tue Mar 19 11:12:59 GMT 2024

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

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

Back to the top