I am trying to add a background image to a Jpanel. Below is the code I'm using      private void createUIComponents() {         JPanel panel1 = new BgPanel();     }      class BgPanel extends JPanel {         Image bg = new ImageIcon("image.png").getImage();         @Override         public void paintComponent(Graphics g) {             g.drawImage(bg, 0, 0, getWidth(), getHeight(), this);         } }   I am using IntelliJ so most of the GUI code is hidden. Shouldn't the custom created JPanel be a BgPanel and therefore display the image? Where have I gone wrong?  I am getting the following when trying to compile:  Exception in thread "main" java.lang.NullPointerException     at testGUI.$$$setupUI$$$(testGUI.java)     at testGUI.&lt;init&gt;(testGUI.java:4)     at testGUI.main(testGUI.java:11)   Full Code:  import javax.swing.*; import java.awt.*;  public class testGUI {     private JButton button1;     private JPanel panel1;      public static void main(String[] args) {         JFrame frame = new JFrame("testGUI");         frame.setContentPane(new testGUI().panel1);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         frame.pack();         frame.setVisible(true);     }      private void createUIComponents() {         JPanel panel1 = new BgPanel();     }      class BgPanel extends JPanel {         Image bg = new ImageIcon("imagelink.png").getImage();          @Override         public void paintComponent(Graphics g) {             g.drawImage(bg, 0, 0, getWidth(), getHeight(), this);         }     } }
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?
Possible to lock focal length on zoom lens? (SELP1650) (This could turn out to be a bone, practical, product-specific query, but this is the internet so the worst that could happen is a 0 rather than a 1.)  Anyhoo: is it possible to lock a zoomable lens to a certain focal length? Is this a typical feature for a lens?  I want to keep my SELP1650 at X mm to help with some creative experiments, but the thing shifts whenever I move my hand against the lens ring. Does SELP1650 (or the body, Sony A6000) specifically have this option?  Or... is there a reasonably non-goofy DIY trick I could pull off, without bricking the thing? (anticipating a sarky 'duct tape' suggestion) How can I show that $ab \sim \gcd (a,b) {\operatorname{lcm} (a,b)}$ for any $a,b \in R \setminus \{0\}$? Let $R$ be a UFD. Then for any two elements $a,b \in R \setminus \{0\}$ $ab \sim \gcd (a,b){\operatorname{lcm} (a,b)}$.   My attempt :  Let $d = \gcd (a,b)$.Then $d|a$ and $d|b$.Then $\exists x,y \in R$ such that $a = dx$ and $b = dy$.Now it is to be shown that $c = dxy$ is the lcm of $a,b$.Which I find difficulty to show.It is clear that $a|c$ and $b|c$. Now if $u$ is any common multiple of $a$ and $b$.Then $dx|u$ and also since $y|b$ we have $y|u$ i.e. $dxy|u^2$ $\implies c|u^2$.But I have to show $c|u$ to complete the proof which I fail to prove.Please help me to complete the proof.  Thank you in advance. Editing photo dimensions in large batches If I had the time, I would go through each and every photo to make sure that the dimensions and quality are pixel perfect. However, I'm in a time crunch, and need to make the couple hundred photos that are 4320 x 3240 into 950x630.   now I could- 1. Upload them into WordPress, uses native image reducing components and J query go from there. 2. Go through each and every photo, reduce file size, and proportion and bring it to Yahoo's PNG processing script.  However, maybe I'm missing a choice or alternative workflow that would allow for processing all of these photos in a clear manner without losing quality or perspectives. Any workflow suggestions? For $G$ group and $H$ subgroup of finite index, prove that $N \subset H$ normal subgroup of $G$ of finite index exists Misplaced navigation bar and question title Appending to the end of a file with NSMutableString What will result in better page ranking in search results: Page views or time spent on page? I've updated my Ubuntu to 19.10 couple of weeks ago and on installation system suggests to change or add shortcut for input source selection despite one was already defined previously. I've added ctrl+shift shortcut and just realized that it somehow overlapped any other ctrl+shift+something shortcuts globally, i.e. when I want to open new window in vscode, it opens new tab and it looks like system doesn't see the shift button press.   I tried to search this combination in shortcuts settings, but it's just not there. Why does my Task Manager window outline keep disappearing? Possible Duplicate:          I'm not sure what the proper term for the window outline is (chrome, I think?), but it keeps disappearing.    As you can see, theres no File->Exit or buttons that allow me to minimize or close this dialog. So instead it stays on top of everything else (unless I 'Switch To' another window). There is also no Processes tab or anything.  Since you cant right click the toolbar or bring up another instance of Task Manager, the only way to actually kill this dialog seems to be restarting. However the next time I bring up Task Manager, it will still refuse to go away.  Anyone know whats going on? I'm running 32-bit Vista SP1. What do people who are using a pensieve look like? As far as I remember from the books, there's no description of what a person using a Pensieve looks like. When Harry is using the Pensieve, he describes it as if he were falling into it, but it's never stated whether his body really enters the Pensieve, because the experience is just told from his point of view.   Now let's say Dumbledore enters his office while Harry was using the Pensieve -- what would Dumbledore see? Is there an answer in the books/canon? How would you handle different aspect ratios in a 2d platformer? How to update Wine to the latest version? "It's time something was / were done about the problem." It's time something was done about the problem.   It is a sentence from Murphy's "Grammar". Using was confused me, for me it should be were. It looks like this clause is in subjunctive mood&mdash;something that is unreal / imaginary, and in that case you always use were for any object.  Unless, of course, it is not the subjunctive mood, what would knock me down. Trying to use "Difference" tool gives out "'QgsWKBTypes' is not defined" error I am trying to separate two overlapping vector layers and find out the difference in QGIS 2.18. I have tried finding difference with layers with points and also with buffers. Both of them give following error:  global name 'QgsWKBTypes' is not defined See log for more details   I have searched the web for this but can't seem to find a solution. Recursively copy files from one directory to another I have all my music in a folder /media/kalenpw/MyBook/Music/ABunchOfOtherFoldersWithFilesInside. I want to copy all of the mp3s to /media/kalenpw/HDD/Music so I used:  cp -R /media/kalenpw/MyBook/Music/*.mp3 /media/kalenpw/HDD/Music   however this only copied the mp3s in the root music folder and did not open any of the artist subdirectories and copy those files.  I was under the impression -R would recursively copy all the files. How can I achieve said goal? How to force nginx to resolve DNS (of a dynamic hostname) everytime when doing proxy_pass? Prove QM-AM inequality $$\dfrac{x_1^2+ x_2^2 + \cdots + x_n^2}n \geq \left(\dfrac{x_1+x_2+\cdots+x_n}n\right)^2$$   I don't think AM, GM can be used here. And simple expansion doesn't help too. What should I do? Comparing SVM and logistic regression Can someone please give me some intuition as to when to choose either SVM or LR? I want to understand the intuition behind what is the difference between the optimization criteria of learning the hyperplane of the two, where the respective aims are as follows:     SVM: Try to maximize the margin between the closest support vectors LR: Maximize the posterior class probability    Let's consider the linear feature space for both SVM and LR.  Some differences I know of already:   SVM is deterministic (but we can use Platts model for probability score) while LR is probabilistic. For the kernel space, SVM is faster (stores just support vectors) Are InnoDB Deadlocks exclusive to INSERT/UPDATE/DELETE? Title of novel with girl who can read minds by observing body language, later communicates with a hive mind on an alien planet's surface As a kid I was greatly influenced by a book where a girl (I believe her name was Marlena) lived in a ship orbiting an alien planet.  The ship was intended to colonize the planet but the humans had encountered difficulty.  People on the surface early on had gone incurably mad.  The planet was covered with single cell organism, but no other life.  Other than the "bacteria" it was sterile.    The girl, along with most of the colonists, was still living on the orbiting ship for the foreseeable future.  The girl had an uncanny knack of reading people's minds by noting minute changes in behavior and body language, kind of like Sherlock Holmes' famous observations.  Eventually she got a chance to go to the surface, and found the planet trying to communicate with her.  In one memorable scene the swirls in the water of a stream formed a face and started trying to call her name, "Eeeena, Aaleeena, Aarleena, Marlena!"  It turns out that the single celled organisms on the planet comprised a hive mind which had tried to communicate telepathically with previous humans by altering their brains slightly, causing the madness.  The girls's brain was different, however, constantly modifying and changing itself so that it was not damaged by the hive mind's attempts to communicate with it.