nullpointerexception

JAVA: Swing JButton componnent (NullPointerException)

若如初见. 提交于 2019-12-24 08:50:11
问题 I am trying to show text - "You pressed Button" when you pressed one of buttons. I am getting an NullPointerException . I have initialized the buttons inside the constructor of the class and after initialization, I called the following method from main() . Here is the code: import java.awt.event.*; import javax.swing.*; import java.awt.*; public class ButtonDemo implements ActionListener{ JLabel jlab; ButtonDemo(){ JFrame jfrm = new JFrame("A Button Example"); jfrm.setLayout(new FlowLayout())

Java.NullPointerException null (again)

吃可爱长大的小学妹 提交于 2019-12-24 08:49:49
问题 I am having another problem with NullPointerException. This time it is highlighting tellen = telno.length() . Beore you ask: There is data in the text file to be read to that variable. All variables were initialized. Buffered Reader is also initialized. Here is a snippet of my code: while((telno = br.readLine()) != null){ name = br.readLine(); surname = br.readLine(); company = br.readLine(); house = br.readLine(); street = br.readLine(); locality = br.readLine(); postcode = br.readLine();

Why am I getting this NullPointerException?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 08:38:36
问题 I can't figure this out. After initializing a Canvas with new Canvas(), referencing it results in a NullPointerException. The doc tells me this can occur when the Canvas is not "enabled", but I don't know what it means to be enabled. I tried to debug it by including while(! cvs.isEnabled()); but the program just hung. What are the conditions that could result in a Canvas not being enabled, and how do I fix them? Exception in thread "main" java.lang.NullPointerException at matt.io

NullPointerException being thrown whenever array member is accessed

夙愿已清 提交于 2019-12-24 08:36:53
问题 I am having an issue with an exception that keeps being thrown every time I attempt to execute the following code. Below is the driver, and below that I will give you the constructor for Room and the playerEnters method. import java.util.Random; import java.util.Scanner; public class ZorkPlayer { public static void main (String [ ] args) { // create a start screen followed by introduction int choice = 0; while(choice != 3) { choice = menu(); switch (choice) { case 1: //begin new game newGame(

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference [duplicate]

你。 提交于 2019-12-24 08:11:56
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 2 years ago . I'm creating an app that list all images in my phone and I'm using media content provider to do it. my problem is I always get this error in my app wherever i run it. 08-28 00:31:27.001 16706-16706/com.chill.leoj.burp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.chill.leoj.burp, PID: 16706 java.lang.RuntimeException: Unable to start activity ComponentInfo{com

What is a NullPointerException, and how do I fix it?

时光毁灭记忆、已成空白 提交于 2019-12-24 06:22:37
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? 回答1: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you

What is a NullPointerException, and how do I fix it?

邮差的信 提交于 2019-12-24 06:22:07
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? 回答1: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you

Null Pointer Exception when referencing main layout

余生颓废 提交于 2019-12-24 06:14:19
问题 I want this relative layout to eventually load an ad at the bottom. public class Main extends Activity { RelativeLayout mLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mLayout = (RelativeLayout) findViewById(R.layout.main); ImageView View = new ImageView(this, null); //example view mLayout.addView(View); Then the Null Pointer occurs below when mLayout is called RelativeLayout.LayoutParams rparams =

NullPointerExceptions when accessing ElasticSearch painless scripted metric aggregation params

落花浮王杯 提交于 2019-12-24 05:56:30
问题 When accessing doc within map_script of a scripted aggregation, I keep getting a null pointer exception. For { "init_script":{ "source":"params._agg['transactions'] = [];" }, "map_script":{ "source":"Debug.explain(params)" <---------------- }, ... } I get { ..., "painless_class":"java.util.HashMap", "to_string":"{doc=org.elasticsearch.search.lookup.LeafDocLookup@133b9d24, _source=org.elasticsearch.search.lookup.SourceLookup@7b812d13, _doc=org.elasticsearch.search.lookup.LeafDocLookup@133b9d24

Why would I be getting a Null pointer exception with Gui input and listener methods?

℡╲_俬逩灬. 提交于 2019-12-24 05:22:05
问题 I am new to Java and I am trying to allow a user to enter an employees first and last name via the Gui and when they press the submit button it activates the listener methods and allows the values entered to be gathered and put in the systems memory My issue is that when I enter the first name it works perfectly but when I enter the last name it does not work at all I press the submit button and the the whole thing goes nuts the error is null pointer exception "AWT event queue". And I can see