The question is simple. I have created a class named "handler" and within its constructor it contains a parameter for "c", a JComponent. When this constructor is called on a certain JComponent, preferably a JPanel, an oval is drawn at the mouse's current coordinates. This is the source code:  import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener;  public class Handler implements MouseListener, MouseMotionListener {  Graphics g;  public Handler() {}  public Handler(JComponent c) {      if (c instanceof JPanel) {         g = c.getGraphics();         g.drawOval(mx, my, 5, 5);     }      if (c != null) {         c.addMouseListener(this);         c.addMouseMotionListener(this);     } }  int mx, my;   public void mouseClicked(MouseEvent e) {     mx = e.getX();     my = e.getY(); }  public void mousePressed(MouseEvent e) {     mx = e.getX();     my = e.getY(); }  public void mouseReleased(MouseEvent e) {     mx = e.getX();     my = e.getY(); }  public void mouseExited(MouseEvent e) {}  public void mouseEntered(MouseEvent e) {}  public void mouseMoved(MouseEvent e) {     mx = e.getX();     my = e.getY(); }  public void mouseDragged(MouseEvent e) {} }   However, this error is thrown:   Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException   Do you guys have any idea about this? If so, please post a solution.  Edit 1 I've done something new. This is my entire new code:  import javax.swing.*; import java.awt.*;  public class Handler extends JPanel {     int mx = MouseInfo.getPointerInfo().getLocation().x;    int my = MouseInfo.getPointerInfo().getLocation().y;   public Handler(BorderLayout bl) {     this.setLayout(bl); }  public void paintComponent(Graphics g23) {     Graphics2D g2 = (Graphics2D) g23;     g2.drawOval(mx, my, 30, 30);     } }   I've reworked the code greatly. Now, it extends JPanel and serves as a replacement to JPanel. So instead of instantiating a new JPanel, I'd call Handler's constructor. It also implements paintComponent, yet the oval still isn't being drawn. It yields no errors, however.
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?
I have a beamer frame with about 150 slides on it.  I want article and handout mode to only show frame 92.    Reading section 8.6.2 of the beamer manual it seems like I should be able to do something like  \begin{frame}&lt;handout:92&gt; ... \end{frame}   but that seems to have no effect--all 150 slides are set in handout mode, overlaying (making the result unreadable).  I have gotten the effect I want by taking all commands within the frame that have an overlay specification and adding "| handout:0" to make them not appear in handout mode.  Annoying, but works.  But for my 150-slide frame the different slides are generated by a PGF \foreach loop so I can't code slide 92 differently from the rest.  But can I do this at the frame's overlay specification?  It seems that the frame's overlay spec really acts differently from other commands.  If I only do  \begin{frame}&lt;92&gt;...\end{frame}   then I get only slide 92 in beamer mode but all slides in article or handout mode. Why has my database connection failed? Recently I have developed software using SQL Server 2012. Now when I try to connect, I get this error message:     Cannot connect to AAFI\SQLEXPRESSA network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) Stop generating "possible duplicate" comments When a question has pending close votes, the system now adds a banner indicating that the question might be a duplicate:    But the first user to vote still generates a possible duplicate comment:    Those comments were always a hack, just like editing the link into the top of the post. The banner eliminated the need for the latter; can we stop generating those comments too? Simulate repeated rolls of a 7-sided die with a 6-sided die What is the most efficient way to simulate a 7-sided die with a 6-sided die? I've put some thought into it but I'm not sure I get somewhere specifically.  To create a 7-sided die we can use a rejection technique. 3-bits give uniform 1-8 and we need uniform 1-7 which means that we have to reject 1/8 i.e. 12.5% rejection probability.  To create $n * 7$-sided die rolls we need $\lceil log_2(  7^n ) \rceil$ bits. This means that our rejection probability is $p_r(n)=1-\frac{7^n}{2^{\lceil log_2(  7^n ) \rceil}}$.  It turns out that the rejection probability varies wildly but for $n=26$ we get $p_r(26) = 1 - \frac{7^{26}}{2^{\lceil log_2(7^{26}) \rceil}} = 1-\frac{7^{26}}{2^{73}} \approx 0.6\%$ rejection probability which is quite good. This means that we can generate with good odds 26 7-die rolls out of 73 bits.  Similarly, if we throw a fair die $n$ times we get number from $0...(6^n-1)$ which gives us $\lfloor log_2(6^{n}) \rfloor$ bits by rejecting everything which is above $2^{\lfloor log_2(6^{n}) \rfloor}$. Consequently the rejection probability is $p_r(n)=1-\frac{2^{\lfloor log_2(  6^{n} ) \rfloor}}{6^n}$.  Again this varies wildly but for $n = 53$, we get $p_r(53) = 1-\frac{2^{137}}{6^{53}} \approx 0.2\%$ which is excellent. As a result, we can roll the 6-face die 53 times and get ~137 bits.  This means that we get about $\frac{137}{53} * \frac{26}{73} = 0.9207$ 7-face die rolls out of 6-face die rolls which is close to the optimum $\frac{log 7}{log6} = 0.9208$.  Is there a way to get the optimum? Is there an way to find those $n$ numbers as above that minimize errors? Is there relevant theory I could have a look at?  P.S. Relevant python expressions:  min([ (i, round(1000*(1-(  7**i )  /  (2**ceil(log(7**i,2)))) )/10)  for i in xrange(1,100)], key=lambda x: x[1]) min([ (i, round(1000*(1- ((2**floor(log(6**i,2))) / (  6**i ))   )    )/10)  for i in xrange(1,100)], key=lambda x: x[1])   P.S.2 Thanks to @Erick Wong for helping me get the question right with his great comments.  Related question: Do you gain current HP when you level up? I have a problem. I have several large equations within the text. And when LaTeX does not manage to put the equation on the same page and moves it to the next one, he spreads the paragraphs of the text in the first page. How could I prevent this? I know about \pagebreak and \newpage, but I do not want to force the \newpage, as the text may move (if I add something later or so on) and the pagebreaks may not be valid. I would like to make LaTeX not to spread the paragraphs over a page automatically. Is it possible?  I tried to make an example:  \documentclass[a4paper,12pt,twoside]{book} \usepackage{amsmath} \begin{document}  LaLaLa\\\  LaLaLa\\\  LaLaLa\\\  LaLaLa\\\  \begin{eqnarray} 123&amp;+&amp;123 \\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ \end{eqnarray}  LaLaLa\\\  LaLaLa\\\  \begin{eqnarray} 123&amp;+&amp;123 \\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ 123&amp;+&amp;123 \nonumber\\\ \end{eqnarray}  \end{document} I had to write the proof to show that an Ideal $P$ of a commutative ring $R$ is prime Ideal if $R/P$ is an integral domain.       let $a,b\in R$ s.t. $ab\in P$ ,        $$ab+P=P\implies(a+P)(b+P)=P\implies\overline a \overline b=0$$  and as $R/P$ is an integral domain either $a=0$ or $b=0$ $\implies a+P=P$ or  $b+P=P$.        $\therefore$ either $a\in P$ or $b\in P$.   Hence, $P$ is a prime Ideal.    Am I correct in writing this or am I making some error... Unable to locate package I keep seeing custom flags in the queue from question askers who are incredibly irritated because there is a big, prominent box at the top of their question. It's just a list of other questions which may have the answer they desire, and is only even displayed to them because the question is not closed yet.  This question may already have an answer here: [list]  But to an ordinary user, it is not at all clear that the box is only shown to them, or that it will go away on its own if their question never actually gets closed. Could the text for this notice be altered to make it more clear that:  They are just suggestions for the person to view. Potentially if they agree with one, they should vote to close their own question as a duplicate of it.  Their question is not closed yet. If they disagree with the duplicates suggested, they should clarify their question and explain why it's not a duplicate.   I was thinking of an altered wording such as:  You might be able to find an answer to your question here: [list] If those answers do not fully address your question, please [edit your question] to clarify your exact problem.  I went with a more direct wording for the bolded title. Since the notice is only displayed to the asker, it makes more sense to talk directly to them in the message rather than making it feel like it's supposed to be addressing the entire audience of the site. Emphasize that only that person is seeing it by talking to them. It would also be helpful to append a &quot;More info&quot; link at the end of the message that links them to some further documentation about duplicates, and explains how the notice works - particularly that it will go away eventually or change to a proper duplicate notice if the question does get closed. Film in which people can time-travel to relive the biggest world disasters; main character changes a destiny, saving many people I saw a film about 10 years ago. It was about people that could live the biggest disasters in the world that had happened again. They could travel in time and see these disasters. There were some plane crashes, metro crashes, Titanic disaster and so on.  But one man (positive main role) saw another bad man who was throwing a coin in the air and this coin fell down. This positive role changed a destiny and saved many people. This saving caused some damages to negative roles in this film. Need for a side book for E. Soper's Classical Theory Of Fields I am reading now E. Soper, Classical Theory Of Fields, now and sometimes it is very hard to follow the equations. So I need a side book on  to read it comfortably. Landau &amp; Lifshitz's book is not helping as its content and topics are very much different. I would like to transfer files between two remote hosts using on local shell, but it seems rsync doesn't support synchronisation if two remotes are specified as follow:  $ rsync -vuar host1:/var/www host2:/var/www The source and destination cannot both be remote.   What other workarounds/commands I could use to achieve similar results? Understanding complete separation for logistic regression Why does logistic regression not converge for a linearly separable data set?   For linear separable data sets the model parameters go to infinity when mimizing the error function (according to Bishop2006, Pattern recognition and machine learning, section 4.3.2). I don't understand why. It must be connected to setting the score function, i.e. the derivative of the error function, to zero.  The error function is given by $E(\mathbf{w})$ as shown in the figure below. Where $\mathbf{t}$ is the target variable vector of the training set and $\mathbf{w}$ the parameter / coefficient vector. The posterior probabiltiy for class 1 is given by  $$y(n) = p(C_1|\mathbf{x}_n) = \sigma(\mathbf{w}'\mathbf{x}_n).$$ Where sigma is the logistic sigmoid function and $\mathbf{x}_n$ is the feature vector for instance $n$ including the predictors.     My second question to logistic regression is if the to posterior probabilities $p(C_1|\mathbf{x}_n)$ and $p(C_2|\mathbf{x}_n)$ sum to one? I am building a drupal site using Views, search API module and user-points module.  I created the "database server", and indexed many fields of nodes.  I created a search page using views and the search API, that present content (image, title etc.) In addition, I want to add to every content in this search view the name of the author that wrote it, his author picture.  I add the Indexed Content: Author relationship. Unfortunately, I can't find a way to add the author picture and the current total point to my view.  Can somebody advice how to do that? Open existing file, append a single line Can't plot with gnuplot on my Mac I am trying to plot with gnuplot on my Mac (OS X 10.8.5). I have installed X11 and XQuartz 2.7.4 and after that I installed gnuplot, but unfortunately gnuplot couldn't plot.   Simple plots like the following fail to render and have no error message to help understand what is amiss:   [1/10/13 $gnuplot &gt;plot sin(x) Is there an exact command for restarting GNOME Shell in Ubuntu 20.04 corresponding to Alt + F2 + 'r' + Enter? Is there a way to restart GNOME Shell other than by using Alt + F2, R + Enter? With respect to the question, I have gone through , but I didn't get what I was looking for. I am looking for a command which exactly does what Alt + F2, r + Enter do. Please note that I am not willing to do the gnome-shell -- replace command... I did check both the things Alt + F2,r Enter and gnome-shell --replace... There is a lot of difference, I found... I want to make it so I always have 50 entities in an area. So when 1 dies/despawns/leaves the area I want it to detect that and summon in a new entity, and yes I do want them to die/despawn/leave the area so preventing those things is not an option. Importing a Single Symbol From a Different Font Does a conducting wire give off measurable radiation?