JAVA | Thread.sleep() error / Nullpointer I am sorry I am beginner in java. For my little adventure game that I am working on, I want to add an delay in my gameLoop actully for testing my graphics.   The problem is I have an loop where the things get printet/paintet on screen (call it how u want :D). When I do that usual I have no problems, but when I add a Thread.sleep (with throws or try&amp;catch) I get an NullPointerExeption somewhere in my program wich has nothing to do with that part here is my code:  GUI CLASS:  package xxx.yyy.zzz;  import java.awt.Graphics;  import javax.swing.JFrame; import javax.swing.JPanel;  public class GUI extends JPanel {  private JFrame frame; private Control ctr;  final int objectSize = 10;  public GUI() {     frame = new JFrame();     frame.setVisible(true);     frame.setSize(800,500);     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     frame.setLocationRelativeTo(null);     frame.add(this);     ctr = new Control(this); }  public static void main(String[] args) {     new GUI(); }  public void paintComponent(Graphics g) {     super.paintComponent(g);     for(int x = 0; x &lt; ctr.getScreenSizeX(); x = x + objectSize) {         for(int y = 0; y &lt; ctr.getScreenSizeY(); y = y + objectSize) {             g.setColor(ctr.getScreen(x/objectSize, y/objectSize));             g.drawRect(x, y, objectSize, objectSize);             g.fillRect(x, y, objectSize, objectSize);         }     }    } }   CONTROL CLASS:  package xxx.yyy.zzz;  import java.awt.Color;  public class Control {  private GUI gui; private Level l1;  private Color[][] screen; private Player player;  private final int screenSizeX = 400; private final int screenSizeY = 300;  public Control(GUI pGUI) {     gui = pGUI;     l1 = new Level(400, 30, true);     screen = new Color[screenSizeX][screenSizeY];     player = new Player(Color.WHITE);      gameLoop(); }  private void gameLoop() {      print(l1);      for(int i = 0; i &lt; 100; i++) {         player.move(1);         print(l1);          try {             Thread.sleep(100);                      //here is my problem!         } catch (InterruptedException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }     }  }  private void print(Level pL) {     if(pL.getSizeX() &gt; 40 || pL.getSizeX() &gt; 40) {         for(int x = 0; x &lt; 40; x++) {             for(int y = 0; y &lt; 30; y++) {                 screen[x][y] = pL.getObjectColor(x + (player.getX() - 10),  y);             }         }     }      else {         for(int x = 0; x &lt; 40; x++) {             for(int y = 0; y &lt; 30; y++) {                 screen[x][y] = pL.getObjectColor(x, y);             }         }     }     gui.repaint(); }  public Color getScreen(int x, int y) {     return screen[x][y]; }  public int getScreenSizeX() {     return screenSizeX; }  public int getScreenSizeY() {     return screenSizeY; }  }   I censored my package xD  Thank you for your replies, sorry I am not familiar with game programming and programming beginner!  EDIT: My Error Log:  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException  at com.zeptosi.snogg.GUI.paintComponent(GUI.java:31) ...
What is a NullPointerException, and how do I fix it? 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?
WMS and WFS queries needs SRS and BBOX parameters.  http://example.com/geoserver/wfs?   service=WFS&amp;   version=2.0.0&amp;   request=GetFeature&amp;   typeNames=namespace:featuretype&amp;   srsName=CRS&amp;   bbox=a1,b1,a2,b2&amp;   For example I have GeoServer to publish WFS. My data SRS is EPSG:4326 and my map SRS is EPSG:3857. So I send a WFS query.  http://example.com/geoserver/wfs?   service=WFS&amp;   version=2.0.0&amp;   request=GetFeature&amp;   typeNames=namespace:featuretype&amp;   srsName=EPSG:3857&amp;   bbox=978393.9621,2680799.4560,-430493.3433,3326539.4710&amp;   Does GeoServer or ArcGIS server give an error? Because my data has EPSG:4326 . Or does GeoServer convert these coordinates internally and find data and send me as EPSG:3857 What are the transactional costs when buying and selling a house? Say I have two Chrome windows open like this:   It seems that the most recently used window always appears on top. In other words, the &quot;Apply Digital Signatures&quot; was the window I had open last. If I were to switch to the window showing the new tab, then the order in which the windows are displayed in the task bar suddenly changes. Is there a way to keep them from shuffling around? I'd like to be able to order them however I want, like tabs in a web browser. (I'd also like to put them across different workspaces.) I'm toying with the jQuery plugin  to implement a branching wizard for a web application. The problem I'm struggling with right now is how to deal with user choices that affect the subsequent workflow and the content and re-ordering of the progress meter of the wizard.  As for now I can think of 3 alternatives.   Static solution: Lay out all possible steps in advance. Though some steps will only be activated if the user makes the appropriate choice. Otherwise, the wizard continues with the next valid step. As an example: If someone doesn't need the "flight transfer option" the wizard simply leaves out all steps concerned with that choice. Fluid solution: Lay out only the default or required steps (happy path scenario). If for instance at some point the user chooses to branch away from the visible path (I need the transfer option) the wizard gets a visual update and also its progress meter. Now, showing all the additional steps. (I'm not sure though if this is visually appealing.) A combination of 1 and 2: This is meant as an extension to 1) and 2) where all the choices are made up-front like in a short enquiry (1st step). Based upon these choices the wizard gets a visual update with the corresponding workflow. If the user wants to change the choice she made she has to re-visit the first step (which creates the potential complexity of not loosing already entered data) I agree that every page in a site should have a unique TITLE, and that every page should have one and only one H1 element, but should the text of each H1 be completely unique too?  Instinctively one would think so, but there are potentially many cases where (IMHO) mind this doesn't make sense and attempting to do so will impair the user experience &amp; presentation of the page - for example, where pages are part of a closely related cluster, e.g. a multi-step process/tool/wizard.  Surely the process name should go in the H1 (e.g. "Pregnancy Planner"), and the current step you're on should be marked up as a H2 (e.g. "Step 1 - Trying for a baby"), rather than shoehorning both into a single H1 together (e.g. "Pregnancy Planner - Step 1 - Trying for a baby")?  Not only does this make the H1 rather long and potentially impact the presentation of the page, I would argue that in combining both into one you also lose semantic goodness, as the page is surely semantically richer by keeping parent (process) and child (step) as separate, nested headings?  Furthermore, the current proposal I have read is that on the first page the H1 should be the name of the process and the first step an H2, but on subsequent pages the same text should not be a H1 at all (just text styled exactly the same as an H1) and the current step should become the H1 instead. For me this is introducing unnecessary complexity to the page authoring/production process, and inconsistency in the semantic structure of the pages within the stepped process.  So it all comes back to the basic assertion that each H1 must be completely unique, which I question. Can you convince me that this should be so and that the cost/complexity of implementing this (especially in situations such as that above) is worth it?  Your thoughts please... During Winterbash 2014, there was a hat called , which was earned by giving an answer scoring 5 or better to question that had a score of −3 or worse at the time of answering and later rose to a score of +3 or better.  I’ve already shared the . Those cases give me a great deal of confidence that this would be a challenging badge trigger that would produce good behavior with a minor tweak. Here are the Red Barons earned on other sites:    (Logan Maingi) Mathematics  (Mike Miller) Mathematics  (Hugo) English Language and Usage  (tchrist) English Language and Usage  (Mr. Shiny and New 安宇) English Language and Usage  (Darth Satan) Science Fiction and Fantasy  (DVK) Science Fiction and Fantasy  (rolfl) Code Review  (Heslacher and Hosch250) Code Review  (Edward) Code Review  (janos and Manny Meng) Code Review  (Mark Mayo, Rory Alsop and MeNoTalk) Travel      (DJClayworth) Christianity  (McMagister) Puzzling   Looking through the timelines, I’m convinced that the answerer’s votes should be excluded from the pre-answer question score calculation. Doing that would have reduced the number of Red Barons to 16 across the network. However, the cost of making a badge harder to obtain is worth the benefit of avoiding giving people an incentive to manipulate question scores¹.  To wrap up, the hat seemed to have encouraged a number of great answers and rescued some questions that would otherwise have been lost to time. My outstanding questions are:   Were there any problems on questions where people were attempting to earn the hat, but failed? (Or any other problems I didn’t observe.) If not, should we  or create a new badge? If we create a new badge, what should it be called?   I’m especially interested in feedback that counters my own bias in favor of this idea. If I’m missing any problems, I’d like to know about them now.    ¹ Several questions were downvoted, answered, edited (sometimes trivially)  and upvoted by the user who earned the hat. My 5 year- old daughter is constantly defiant! My 5-year old daughter is very defiant.  It started getting bad about 6 months ago. She doesn't do what she is told, and any time she hears the word "no" she throws terrible, dramatic fits, screaming ridiculously loud, and in some cases hitting.  She refuses to make eye contact when I warn her to stop doing something even when I am down at her eye level and it takes multiple orders to finally get her to look at me. She constantly tells me no.  I feel like I constantly tell her no and that she feels this gives her the right to tell her father and I no.  I have tried time outs which are not effective at all; she only throws a fit the whole time, never seeming to run out of wind. Spankings are only effective until the shock of the action itself wears off and then she returns to the same behavior.  My husband and I recently took away ALL of her toys/ possessions being she is a pretty materialistic child (she loves getting toys and always wants something new). We told her that if she was good and listened and stopped telling us no and throwing fits, that after three days we would let her choose three boxes of toys to bring back in her room. This worked but as soon as she got those three boxes unpacked, we packed them back up because she went right back to the no's and fit-throwing within a few hours.  I am mainly the one disciplining her and I feel she is definitely the most defiant with me. I believe in explaining to her why things are not OK and why I tell her no, but I really don't feel it helps and I never feel as if she listens to what I tell her.  I am at my wits' end and feel like a failure of a mother. She is my first and only child, and the only grandchild on both sides of our family. She is an angel at school but home is completely different.  I need help figuring this out but nobody I talk to really has any advice for me. I am at the point where I am wondering if she or I need counseling because I feel out of options. My friend is buying a digital point-and-shoot camera, which he wants to use to click family pictures including a lot of pictures of their newborn son.  What camera qualities should he be looking for while buying? Does a conducting wire give off measurable radiation? Quadrilateral problem with midpoints of diagonals For an arbitrary convex quadrialteral $ABCD$:   $$AF=FC, BE=ED, GI=IH$$  Prove that points $F$, $E$ and $I$ are collinear.  I was able to solve the problem by using vectors and I think that it can be also solved analytically but I wanted some more elegant proof, more in the spirit of Euclid. How to boot Ubuntu persistent live USB on Android? I'm discovering the possibilities offered by persistent live USB using Ubuntu 19.10 and I was wondering if it would be possible to boot with Ubuntu on Android (i.e. using your computer capabilities through your smartphone) using those multi-plug USB sticks which have both USB3 and micro-USB2.  In other way: can I get some kind of a boot menu on an Android device in order to boot with a persistent live USB in order to access my Linux computer tools and setup from a wider range of devices? I came across this statement while studying electric currents and I am confused:  "There is no electric field inside a conductor. Hence no current can flow through it".  Is there a fallacy in this statement?  Any help would be appreciated.  The conductor being discussed is ideal. What is the driving force for the current in this case? Doubling the tails in two-sample permutation test Suppose we have two samples and we wish to determine if they are drawn from the same distribution, the samples A,B being composed of some integers say.  If we test this using a two-sample permutation test, specifically by looking at permutations where the differences in the means of the samples are as extreme as the difference observed: is there any reason to think that we can calculate the two-tailed p-value by looking at one tail and doubling the probability?  This is what it appears to say in my lecture notes, but I don't understand why we could assume that the tails are symmetrical (or why it doesn't entail that assumption). Explanations were not forthcoming. Ubuntu 18.04 bond with netplan duplicate MAC address after cloning Using Joint Distributions and conditional probabilities This exercise is particularly confusing me because I do not understand the distribution of 'X-Y' or how to calculate the probabilities Optional Methods in Java Interface How can I make a Random Number Generator with vanilla redstone? I assume that the following sentences are grammatically correct:   He resents your being more popular than he is. Most of the members paid their dues without my asking them. They objected to the youngest girl's being given the command position. What do you think about his buying such an expensive car? We were all sorry about Jane's losing her parents like that.   I'm still getting used to this possessive gerund structure. It sounded so weird to me at first. Is the structure used in both formal and informal contexts? Are there any alternative structures that result in the same meaning and are more frequently used? (Examples taken from ) Can you show me a continuous function $f \colon \mathbb{R}^n\to\mathbb{R}^m$ that satisfies $f(a+b)=f(a)+f(b)$ but is not linear?   We have that  $$f(0)=f(0+0)=2f(0)\implies f(0)=0\\ f(x-x)=f(0)=f(x)+f(-x)=0\implies f(-x)=-f(x)\\ f(nx)=f(x+x+\dots+x)=f(x)+\dots+f(x)=nf(x)\quad \forall n \in \mathbb{N}$$ But $$ f(-nx)=-f(nx)=-nf(x) $$ So: $$ f(ax)=af(x) \quad \forall a \in \mathbb{Z} $$ Identify this 80's movie about a force-field shaped like a bubble