Hi all,
If i have a class - Product, it has 2 fields, String name, and Bitmap productImage. If I try to access the bitmap from another class like Bitmap b = p.productImage; I get null (i have tried many different ways - directly accessing or via a getter method) but if i try to access the string variable of the object it's fine. i know the bitmap has been created. Do i have to convert the bitmap into something else? or is my way of doing it correct?
Please hlp, i'm going out of my mind with this nullpionterexception.
3 1598 Markus 6,050
Recognized Expert Expert @brendanmcdonagh
Seeing the code I may be able to spot an error; nothing jumps out at me from your description.
Mark.
There's a bit of it Marcus, I have been programming a blackberry app talking to a server. It it Java though, let me know if you would be willing to help me out, I qouldn't like to just post 2 1/2 classes without your ask me to. Here' the method that fills my list - public void drawListRow(ListField listField, net.rim.device.api.ui.Graphics g, int index, int y, int width)
-
{
-
Product[] data;
-
-
Product p = (Product) get(listField, index);
-
-
-
int ypos = y + UPPER_MARGIN;
-
int xpos = TEXT_MARGIN;
-
-
String str1 = "line 1";
-
-
String str2 = "line 2";
-
-
Log.info("tdrawrow" + vector.size());
-
-
//Product p = (Product)vector.elementAt(0);
-
this.productId = p.productId;
-
this.productName = p.productName;
-
this.productPrice = p.productPrice;
-
this.productOffer = p.productOffer;
-
this.productOfferValidity = p.productOfferValidity;
-
-
if(p.getProductImagePath() != null)
-
{
-
try
-
{
-
try
-
{
-
b = p.productImage;
-
this.productImagePath = p.getProductImagePath();
-
Log.info("This is productimage" + productImagePath);
-
-
}
-
catch(Exception jjj)
-
{
-
Log.info("Error tttt" + jjj);
-
}
-
-
-
int indent = 20;
-
-
Log.info("b != null");
-
g.drawBitmap(0, y, 16, 16, b, 0, 1);
-
Log.info("drawn");
-
-
g.drawText(productName, indent, y, DrawStyle.ELLIPSIS, width - indent);
-
Log.info("drawn text");
-
}
-
-
catch(Exception tt)
-
{
-
Log.info("This is productimage error" + tt);
-
int indent = 0;
-
g.drawText(productName, indent, y, DrawStyle.ELLIPSIS, width - indent);
-
}
-
}
-
this.productRating = p.productRating;
-
this.productQuantity = p.productQuantity;
-
-
-
Log.info("End of method");
-
}
-
-
public Object get(ListField listField, int index) {
-
return vector.elementAt(index);
-
}
-
-
public int getPreferredWidth(ListField listField) {
-
return getWidth();
-
}
-
-
public int indexOfList(ListField listField, String prefix, int start) {
-
return getSelectedIndex();
-
}
-
-
-
-
-
-
}
Let me know if you want to see product, product creates the image from a utils class. It works when i just show the image in product class itself.
p.s. My two variable class was hypothertical, there are string variables for name, price, imagepath, offers, offer validity, etc and then the bitmap variable.
JosAH 11,448
Recognized Expert MVP @brendanmcdonagh
There is nothing special about a Bitmap or any other type: if a field of that type is reachable from outside (e.g. it is a 'public' field) it is either null both inside and outside that particular object that holds the field or it isn't. Something else is wrong in your code. System.out.println( ... ) sprinkled in at strategic places is your friend here.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in...
|
by: Erwin |
last post by:
At the moment I'm using a report which contains an indicator to show
if a Service group of the company isn't working well or is working
perfectly. This indicator is a "*" which looks like a traffic...
|
by: deko |
last post by:
I have a table that contains a bunch of pictures. When the user selects a
particular image in a form, I need a way to extract the selected bitmap
image (stored in an OLE Object table field) to the...
|
by: Dennis |
last post by:
I am trying to implement drawing on a bitmap and using bitblt to transfer
it to the control graphics object in the paint event. It seems to draw on
the bitmap ok but doesn't get transferred to the...
|
by: Travis Oliphant |
last post by:
This post is to gather feedback from the wider community on PEP 357. It
is nearing the acceptance stage and has previously been discussed on
python-dev. This is a chance for the wider Python...
|
by: Hamed |
last post by:
Have I posted the message to wrong newsgroup?
Or
Does the question is so much strage?
Would someone please kindly direct me to a true newsgroup or resource?
Best Regards
Hamed
|
by: Dave Harvey |
last post by:
I have developed a standard .NET control which displays medical images and
works fine in applications, but increasingly, my customers are wishing to use
it in an ASP.NET environment, so I am...
|
by: \Frank\ |
last post by:
I trying to learn what a Bitmap is. Not a Managed Bitmap Object but one
that, for example, comes from the clipboard with CF_BITMAP.
I'm guessing that a CompatableBitmap is an array of indices...
|
by: =?Utf-8?B?ZWRkeWN0YW0=?= |
last post by:
When creating a Bitmap object in C# with Bitmap temp = new Bitmap("(filename
here)";
What is put into memory? Is it just the bitmap info header or is the entire
bitmap loaded into memory?
If it...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |