DocumentListener isn't printing a message I was trying to write a program which would give me a message when something (xx) in this case is typed, but it doesn't print a message. Can you please tell me why that happens ?  I've also checked the code if it's equal to xx when I type it, and it is.   import javax.swing.*; import java.awt.*; import javax.swing.text.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; class acc { public static void main(String[] args) { ramka ramka = new ramka(); panel panel1 = new panel(); ramka.show(); ramka.add(panel1); } } class ramka extends JFrame {   public ramka()  {   setSize(800, 600);      setTitle("Super duper programer");   Container kontener = getContentPane();   textfield pole = new textfield();   kontener.add(pole);   setDefaultCloseOperation(EXIT_ON_CLOSE);     sluchacz listener = new sluchacz();   pole.getDocument().addDocumentListener(listener);  }  } class panel extends JPanel {  public void paintComponent(Graphics g)     {   super.paintComponent(g);  } } class textfield extends JTextField {  } class sluchacz implements DocumentListener  {   @Override   public void changedUpdate(DocumentEvent e)   {}    @Override     public void removeUpdate(DocumentEvent e){}   @Override       public void insertUpdate(DocumentEvent e)            {           try           {          String input = e.getDocument().getText(0, e.getDocument().getLength()).trim(); if(input == "xx") {     String message = JOptionPane.showInputDialog("You've just typed ''xx''"); }     }      catch(BadLocationException ex)      {         }           } }
How do I compare strings in Java? I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
How to programmatically login/authenticate a user? Is this the correct use of the question mark?  Should it be at the end outside of the closing bracket?  See example below     How do we deliver it? (to the learner) I drew a parallelepiped that is spanned by three vectors, and we know the volume is given by the absolute value of the determinant of the matrix - with the three vectors arranged in rows (or columns, since $detA = detA^T$).  How can I draw the tetrahedron from this parallelepiped to convince myself it is indeed 1/6th of the volume, i.e., 1/6 * |detA|?  Thanks, How do I change my Minecraft username during the 30-day restriction? Creating Layer in GeoServer using REST As part of a possible solution to   I want create a layer in GeoServer via REST that supplies a SQL statement along with a userid. I think i would  and publish it. I need to do this all in REST. Does anyone have any code examples? I would like to convert a Mp4 file in HD into a Mp4 file of lower resolution. Is there any software that can be used for this? What is the easiest way to duplicate an activerecord record? I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the id).  What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do this. Perhaps something like this:  new_record = Record.copy(:id) In the Stack Exchange Android app, Achievements section I can see only Today's achievements. No Yesterday, Last 7 days, Last 30 days, ... details.  Previously in the 1.0.85 version itself I saw all the achievements.   I  refreshed the page many time, but still seeing Today's achievement only.  Screenshot for reference:     App Version: 1.0.85 Device Manufacturer: Motorola Device Model: XT1033 OS Version: 5.1 (2) "Delete this answered question?" when the only answer is deleted Looks like there's a small bug in the UI: I posted a question here on meta.SE which ended up being just something dumb I was doing and no use to anyone in the future. At first I posted an answer saying what the dumb thing was, but then I realized that the whole thing had no value, so I deleted the answer, and then deleted the question — whereupon it asked me:  Delete this answered question? We do not recommend deleting questions with answers because doing so deprives future readers of this knowledge. Repeated deletion of answered questions can result in your account being blocked from asking. Are you sure you wish to delete?  (Screenshot below) Probably shouldn't ask (or add to the tally) if the only answers are deleted ones... Mid-2017  started publishing monthly updates. This post will continue that effort into 2018. (.)  Updates are posted at the beginning of the month. They cover what was done last month, what is still in progress and new work that will be started in the current month.  Updates:      (CoC, nav, OpenID, responsive design, bugs, campaigns)  (CoC, comment flags, nav, OpenID)  (question wizard, nav, user survey, OpenID)  (tag watching, GDPR)  (responsive design, tags, teams)  (responsive design, OpenID, teams, sponsorship)  (responsive design, facebook auth, question lists, teams)  (newsletter, sign up, Documentation reputation, channels)  (top bar issues, hats, question template) Show $\,p\mid 9^q -1 \implies q\mid p-1$ for odd primes $p$ and $q$ If $p$ and $q$ are odd primes show that $$p|(9^q -1) \implies q|(p-1).$$ ....  I am having difficulty to prove this.  Yes that was the question I have misunderstood between 9 and q!!! How far does a rogue move when dashing twice using Cunning Action? A rogue receives a bonus Cunning Action, and one option is to Dash. My understanding is a Dash allows a player to move up to twice his speed for his turn.  If a rogue is using a regular action to Dash (hence, is already dashing) can he also use his cunning action as a bonus to Dash again — effectively moving 4 times normal speed in a turn? Need help to understand Maximum Likelihood Estimation for multivariate normal distribution? In maximum likelihood estimation for the parameter, mean $\mu$ of multivariate normal distribution, I end up with the following result:  $\mu_{MLE} = \dfrac{1}{n}\sum_{i=1}^n x_i$  The way I understand the above equation is the following way below, but I am wondering if the above equation means the following equation:  $\mu_{MLE} = \begin{bmatrix}\mu_1\\\mu_2\\\vdots\\\mu_n\end{bmatrix} = \begin{bmatrix}\dfrac{1}{n}\sum_{i=1}^n x_1\\\dfrac{1}{n}\sum_{i=1}^n x_2\\\vdots\\\dfrac{1}{n}\sum_{i=1}^n x_i\end{bmatrix} = \begin{bmatrix}E(X_1)\\E(X_2)\\\vdots\\E(X_n)\end{bmatrix} = \begin{bmatrix}\bar{X_1} \\ \bar{X_2} \\ \vdots \\ \bar{X_n}\end{bmatrix}$   And also Maximum Likelhood Estimation for $\Sigma$, I have ended up with the following equation:  $\Sigma_{MLE} = \dfrac{1}{n}\sum_{i=1}^n(x_i-\mu)(x_i-\mu)^T = \begin{bmatrix}Var(\sigma_{11}) &amp; Cov(\sigma_{12}) &amp; \dots &amp; Cov(\sigma_{1n}) \\ Cov(\sigma_{21}) &amp; Var(\sigma_{22}) &amp; \dots &amp; Cov(\sigma_{2n}) \\ {}&amp; \vdots&amp;  \\ Cov(\sigma_{n1}) &amp; Cov(\sigma_{n2}) &amp; \dots &amp; Var(\sigma_{nn})  \end{bmatrix}$  Somehow, I got the equation following some algebraic steps, but I can't see how this part, $\dfrac{1}{n}\sum_{i=1}^n(x_i-\mu)(x_i-\mu)^T$, works and produces the covariance matrix. Hope to hear some explanations. Today I found my first ever (to the best of memory) emoji in a post.        Having no idea this was even possible I came here looking for some history. I found there is an  tag. There seems to be consensus that they add little to no value on SE per  &amp;  we also know they don't translate well on all devices    I don't find any history other then this one post  where there is any focused attempt to support them. I don't find any history of discussion on supporting them.    Two questions   Is it possible to disable emojis across Stack Exchange?   If yes   Should we disable emojis across Stack Exchange? Usernames as Advertising or Spam? With Windows 7, why is an entry in the hosts file not working? I updated some entries in the  at C:\WINDOWS\System32\drivers\etc.  As a test, I decided to make Google point to 127.0.0.1.  # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #      102.54.94.97     rhino.acme.com          # source server #       38.25.63.10     x.acme.com              # x client host  127.0.0.1       localhost ::1             localhost 127.0.0.1       google.com   This works fine on Windows Vista, but not on Widows 7. When I type google.com into my browser, it goes directly to Google's website.  I am not using a proxy server, and I think there might be some temporary DNS settings that need to be flushed, but I'm not sure.  Does anyone know how to fix this? Prove every element of $G$ has finite order. How to integrate $\int\sqrt{x^2+1}dx$ distance between a line and a point vector formula What is the value of $\arctan(1/2)+\arctan(1/5)+\arctan(1/8)$?