There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Help with solving a NullPointerException issue


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
BDCOXII's Avatar
Junior Member with 2 posts.
 
Join Date: Jun 2006
Experience: Intermediate
10-Jun-2006, 01:22 PM #1
Help with solving a NullPointerException issue
I am working on a assignment. I am attempting to extend an existing class. I have unit tested my code. However, I have one method in my new class that has been giving me fits for the last couple of days. When I unit test my code, I am receiving NullPointerExceptions at a particular line in this code. I've rearranged the logic in this method many times without success. Will someone please take a look at my code below and provide me with some help or any suggestion. The method for which the exception is being thrown from is the addStatementBullet. This method is the last method in the code snippet below. Also, I've indicated, within the method, the statement that is throwing the exception. Your help will be greatly appreciated.




package practiceTEPT;


import java.io.*;
import java.io.File.*;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import com.aspose.slides.*;
import com.aspose.slides.Shapes;
import static practiceTEPT.ClearanceLevel.*;

/**
*
*/
public class TeboSlide extends Slide {

Rectangle body;
Rectangle[] classifiedBox = new Rectangle[2];
Rectangle titleBox;
Rectangle iconImageBar;
Rectangle subTitleBox;
int y=0;

/** Creates a new instance of TeboSlide */
public TeboSlide(ClearanceLevel slideClearanceLevel, String slTitle, String slSubTitle) {

super();

try{

String testText = "";

//For image Icon Bar
iconImageBar = super.getShapes().addRectangle(30,100,5650,600);
iconImageBar.getLineFormat().setShowLines(false);
iconImageBar.getFillFormat().setType(FillType.PICTURE);
InputStream iconInStream = new BufferedInputStream(new FileInputStream("C:\\NetBeansWorkspace\\TEPT\\NewCookBook\\tItemsGenerator\ \tIconGrouped.emf"));
Picture iconRectanglePicture = new Picture(super.getParent(), iconInStream);
int iconPictureId = super.getParent().getPictures().add(iconRectanglePicture);
iconImageBar.getFillFormat().setPictureId(iconPictureId);

//for classified rectangles
//Rectangle[] classifiedRect = new Rectangle[2];
classifiedBox[0] = super.getShapes().addRectangle(100,50,5560,100);
classifiedBox[1] = super.getShapes().addRectangle(100,4200,5560,100);

for (int index=0; index < classifiedBox.length; index++)
{
classifiedBox[index].addTextFrame(slideClearanceLevel.getClearanceLevelDesignation());
classifiedBox[index].getLineFormat().setShowLines(false);
if(index==0)
{
classifiedBox[index].getTextFrame().getParagraphs().get(0).setAlignment(TextAlignment.RIGHT);
}
else{
classifiedBox[index].getTextFrame().getParagraphs().get(0).setAlignment(TextAlignment.LEFT);
}
classifiedBox[index].getTextFrame().getParagraphs().get(0).getPortions().get(0).setFontColor(ja va.awt.Color.BLACK);
classifiedBox[index].getTextFrame().getParagraphs().get(0).getPortions().get(0).setFontHeight(( short)17);
classifiedBox[index].getTextFrame().getParagraphs().get(0).getPortions().get(0).setFontBold(tru e);
}

//for the slide title rectangle
titleBox = super.getShapes().addRectangle(100,200,5560,200);
titleBox.addTextFrame(slTitle);
titleBox.getLineFormat().setShowLines(false);
titleBox.getTextFrame().getParagraphs().get(0).setAlignment(TextAlignment.C ENTER);
titleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setFont Color(java.awt.Color.BLACK);
titleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setFont Height((short)36);
titleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setFont Bold(false);

subTitleBox = super.getShapes().addRectangle(675,530,3060,150);
subTitleBox.addTextFrame(slSubTitle);
subTitleBox.getLineFormat().setShowLines(false);
subTitleBox.getTextFrame().getParagraphs().get(0).setAlignment(TextAlignmen t.LEFT);
subTitleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setF ontColor(java.awt.Color.BLACK);
subTitleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setF ontHeight((short)17);
subTitleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setF ontItalic(true);
subTitleBox.getTextFrame().getParagraphs().get(0).getPortions().get(0).setF ontBold(false);

//For slide body
body = super.getShapes().addRectangle(100,750,5560,3350);
body.getLineFormat().setShowLines(false);

addStatementBullet(testText);


}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}

public Rectangle getBody(){

return body;
}


public void addStatementBullet(String text){

int x=0;
Paragraph paragraph = new Paragraph();
try{
if(y==0){
this.getBody().addTextFrame(text); //<-- java.lang.NullPointerException thrown here
this.getBody().getTextFrame().setX(100);
this.getBody().getTextFrame().setY(750);
this.getBody().getTextFrame().setWidth(5560);
this.getBody().getTextFrame().setHeight(3350);
this.getBody().getTextFrame().setWrapText(true);
x=y;
y++;
}
else
{
paragraph.setText(text);
x = this.getBody().getTextFrame().getParagraphs().add(paragraph);
}
this.getBody().getTextFrame().getParagraphs().get(x).setHasBullet((short)1) ;
this.getBody().getTextFrame().getParagraphs().get(x).setBulletColor(java.aw t.Color.BLACK);
this.getBody().getTextFrame().getParagraphs().get(x).setBulletOffset((short )5);
this.getBody().getTextFrame().getParagraphs().get(x).setTextOffset((short)6 0);
this.getBody().getTextFrame().getParagraphs().get(x).getPortions().get(0).s etFontHeight((short)24);
}
catch(PptEditException ppt)
{
System.out.println(ppt.toString());
}
y++;

}


}
covert215's Avatar
Account Disabled with 2,651 posts.
 
Join Date: Apr 2006
Experience: Web Designer
10-Jun-2006, 04:25 PM #2
testText is null...put some actual text into there
BDCOXII's Avatar
Junior Member with 2 posts.
 
Join Date: Jun 2006
Experience: Intermediate
10-Jun-2006, 07:40 PM #3
Thanks for the reply!
covert215's Avatar
Account Disabled with 2,651 posts.
 
Join Date: Apr 2006
Experience: Web Designer
10-Jun-2006, 10:10 PM #4
did that help?
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:36 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.