Java Action listener not outputting results I am learning Java in school, and we are learning to make GUI's.  Toady we are doing Menubars and such, which I think I understand, and adding menuitems, which I understand. But when I want them to do something when a user clicks on them. I am lost.   Here is my code of the UI:  package UserInterface;  import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*;  /**  *  * @author Jesse  */ public class AirlineReservation {      private JFrame frame;     private JMenuBar menuBar;     private JMenu fileMenu;     private JMenuItem addAirport;     private JMenuItem addAirline;     private JMenuItem addFlight;     private JMenuItem exit;     private JMenu aboutMenu;     private JMenuItem bookFlight;     private JMenuItem aboutInfo;     private JMenu bookMenu;      public AirlineReservation() {         initComponents();     }      private void initComponents() {         frame = new JFrame("Airline Reservation ");         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         frame.setSize(300, 300);         frame.setVisible(true);          // Initializing the JMenuBar         menuBar = new JMenuBar();         frame.setJMenuBar(menuBar);         // Initializing menu items         addAirport = new JMenuItem("Add Airport");         addAirline = new JMenuItem("Add Airline");         addFlight = new JMenuItem("Add Flight");         exit = new JMenuItem("Exit");         // Initializing the JMenu and adding JMenuItems         fileMenu = new JMenu("File");         fileMenu.setMnemonic('F');         fileMenu.add(addAirport);         fileMenu.add(addAirline);         fileMenu.add(addFlight);         fileMenu.add(exit);         menuBar.add(fileMenu);         fileMenu.addActionListener(new FileMenuAction());          //initializing the Jmenu and adding JMenuItems (bookFlight)         bookFlight = new JMenuItem("Flight Reservation");         bookMenu = new JMenu("Book");         bookMenu.setMnemonic('B');         bookMenu.add(bookFlight);         bookMenu.addActionListener(new BookMenuAction());         menuBar.add(bookMenu);          aboutInfo = new JMenuItem("dhdhd");         aboutMenu = new JMenu("About");         aboutMenu.add(aboutInfo);         aboutMenu.addActionListener(new AboutMenuAction());         menuBar.add(aboutInfo);     }      private class FileMenuAction implements ActionListener {          @Override         public void actionPerformed(ActionEvent e) {             if (e.getActionCommand() == "Add Airport") {                 System.out.println("Add Airport Clicked");             } else if (e.getActionCommand() == "Add Airline") {                 System.out.println("Add Airline Clicked");              } else if (e.getActionCommand() == "Add Flight") {                 System.out.println("Add Flight Clicked");             }         }     }      private class BookMenuAction implements ActionListener {          public void actionPerformed(ActionEvent e) {             if (e.getActionCommand() == "sjsjsjs") {                 System.out.println("fjfhfhf");             }         }     }      private class AboutMenuAction implements ActionListener {          public void actionPerformed(ActionEvent e) {}     } }   the problem is that when I click on a menuitems, it seems as if my actionlistener does not catch the click? It has to be a small logical error, and I can seem to put my finger on it :(
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?
Which personal pronoun is appropriate in single-author papers - 'I' or 'we'? Could the use of 'I' be considered egotistical? Or will the use of 'we' be considered to be grammatically incorrect? Work the Spring There's a book that I read several years ago that I'd like to find.  However, I cannot remember enough about it to find it myself.  Neither the title nor author remain in my mind, nor any keyword or phrase that's unique enough for the Grand Google to nail for me.  Hence my desperate plea here.  In the book, there is an interstellar civilization composed of several power blocks.  The entire civilization did not fill the galaxy, but it did span several stellar systems.  Maybe 10s or 100s.  I seem to remember that one of the civilizations was a decentralized group referred to as the Brotherhood and they seemed to have been keen on preserving old learning and political ideals.  A derelict alien spacecraft from outside all of this had been discovered and at least two of the power blocks sent ships to recover it.  I don't recall if they knew at the time about the power the alien ship had, but they must have had some clue since there was some urgency in capturing this ship.  One of the ships sent to capture the Alien craft was commanded by somebody who was rather shaken up, to say the least.  He had had some big trauma in his past (like... the last ship he captained was annihilated with all hands.) so he was kinda bummed out about things and wasn't really putting his heart into getting this done.  He was assisted by the ship's AI who had a lot of soul-to-soul chats with the captain, and at one point almost relieved him of command because he was just not getting the job done.  I think the ship's name was Boaz.  These were the "good guys".  There was at least one other ship sent from the "bad guys."  The alien craft had some remarkable powers.  The interior volume was apparently infinite and the operators could see and manipulate anything in the universe.  There might have been some example given where all the rats somewhere were found and disposed of.  Whoever had control was tempted by the ole absolute power corrupts absolutely problem, but nobody but nobody could stop them because of their power.  They could eat and multiply within the ship and become real bad-asses.  But alas... (or hurray, depending upon which side you're one) everything fails eventually, and whoever controlled the ship would eventually succumb to some horrible end.  Whereupon the ship became derelict again until some other lucky race found it and repeated the cycle.  The ship had an AI that was real interested in taking the power for itself, but there was some mechanical, spring-loaded, mechanism outside of its control that needed to be worked in order to execute power.  The AI apparently never figured out how to "work the spring" and this made him crazy angry.  The ending is equally foggy for me.  I'm pretty sure the good guys got the ship.  They agonized over what to do with it.  Apparently it was indestructable and nobody wanted to taste the temptation of all that power.  In the end they dumped it on the surface of a neutron star.  There it sat forever more, probably with the crazy AI really pissed off about being there.  If you've read this book, you'll recognize it immediately from these clues.  I'm looking forward to finding out the name of this book.  Thanks! Cantrips seem to be the only type of spell that cares only about your class level. However, in the multiclassing section they are not mentioned, does this mean that cantrips use your character level, instead of your class level?  Does this mean a Warlock 2 / Fighter 15 can cast an Eldritch Blast with 4 beams just like a level 17 Warlock? What is the difference between a "link function" and a "canonical link function" for GLM What's the difference between terms 'link function' and 'canonical link function'? Also, are there any (theoretical) advantages of using one over the other?  For example, a binary response variable can be modeled using many link functions such as logit, probit, etc. But, logit here is considered the "canonical" link function. Prove that $C\exp(x)$ is the only set of functions for which $f(x) = f'(x)$ Find the greatest value of $a^2\cdot b^3$ where $a+b=10$ Find the greatest value of $a^2\cdot b^3$ where $a,b$ are positive real numbers satisfying $a+b=10$. Determine the values of $a,b$ for which the greatest value is attained.  At first I tried to find the value by putting $a=10-b$, I found a expression, but I got not way to do anything.   If we apply A.M-G.M. inequality, I think we found the minimum value or something else. It is a pre-Olympiad level problem. So I need some answers or some good hints. How to cd into a directory with this name "-2" (starting with the hyphen)? I have a directory named:  -2   I want to cd into it but the cd complains:  bash: cd: -2: invalid option   With no success, I've tried:  cd "-2" cd '-2' cd \-2   Any solution?  Edit: no file browsers like mc, etc. available on the server. Remove "Set as desktop background" from Windows context menu When I right click an image file in Windows, one of the context menu options is "Set as desktop background". I know some entries can be , so I'd like to know if it's possible to remove the "Set as background" option.  Note that while  can be found under HKEY_CLASSES_ROOT\, the "set as background" option seems to be located somewhere else. Derivative of $f(x)=|x|$ What is the origin of "man on the spot"? What is the origin of "man on the spot" ?   defines on the spot and uses as an example man on the spot.     on the spot -  at the place in question; there; "they were on the spot when it happened"; "it had to be decided by the man on the   spot" (Emphasis added)   Some evidence suggests that the origin of the phrase refers to decisions made by officials of the past British empire and actions taken by them. how to hide files from package explorer Are immutable arrays possible in .NET? Is it possible to somehow mark a System.Array as immutable.  When put behind a public-get/private-set they can't be added to, since it requires re-allocation and re-assignment, but a consumer can still set any subscript they wish:  public class Immy {     public string[] { get; private set; } }   I thought the readonly keyword might do the trick, but no such luck. How to set metadata for music files? In windows music files have metadata like artist name, album name associated with them. How is this metadata stored. Is it stored in file system like other file attributes or is it part of MP3 data that Windows Explorer extracts using a MP3 reader plugin?  Is it possible to read/change this information in Linux? Is it possible with commandline?  (I know these attributes can be set using Rhythymbox or some music player but I'm curious if these could also be set directly. Like in Windows the windows itself shows you artist information if you right click the file and open properties dialog) 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) Am I technically allowed to look up cards during a Magic tournament match? Am I allowed to look up a card during a game, if it's being played with serious Rules Enforcement? Either to read the full card from the Gatherer, or to try to find the exact card I'm vaguely thinking of.  Two possible scenarios:   An opponent has revealed a card previously, and I want to remember the exact details. (Something like the exact wording of a sorcery, mana cost, keywords on a creature, subtypes, etc. etc.) I have a "name a card and remove it from the opponent's deck" type card, and I want to, say, ask google for "Blue Gearhulk" to remember that it's that that one is called "Torrential Gearhulk".   Obviously, in casual or semi-casual games neither of these are a problem. Any reasonable opponent will just re-reveal the known card (assuming it IS still guaranteed to be known) or will accept "I name the Blue Gearhulk".  Also obviously, it seems unlikely that I (or anyone else) would get to the stage of playing at the REL without knowing the cards too thoroughly for this to be relevant.  But in principle... is it permitted? Or not? (and if not, is there a good reason, or just "we decided 'No'"?) Why Are There So Many Double Initials in Comic Books? Not being a comics expert, I can't be sure, but I think this applies mostly to Marvel comics.  Why do so many characters have double initials?  There's Pepper Potts, Reed Richards, Sue Storm, Peter Parker and I think at some times there was Bruce Banner (when it wasn't David Banner).  Is this an inside joke or is there some reasoning for this? Is it possible to "hack" a MacBook so as to be able to install macOS Mojave? Constrains relationship I have the following design. Each user has it's own contacts, it's own hosts and assign those to a domain which belongs only to him.   I want to insure that the host you assign to the domain belongs to the user that domain is assigned to.  Is it something that I have to insure in my application logic?  If I set domains.user_id foreign key to reference host.user_id and user_id.id does it eliminate my issue?    By the way can anyone suggest me a better design for my schema? Watts P.M.P.O. and audio equipment power I am a beginner in electrical engineering, and to begin learning I decided to look into audio amplifiers. I have seen that the power of audio amplifiers is often described in the units of watts, watts RMS, and watts PMPO. So far, the only one of those units that I think I understand is watts. For instance, I just recently made . If I think: &quot;What is the power of my amplifier supposed to be?&quot;, then my thought process goes like this:  The transistors I used are the TIP120, which have a maximum rated power of 65W. Then, I decide that 60W is a safer maximum which would be reached if my amplifier runs 19V through one of my 6Ω speakers. Therefore, the power of my amplifier is 2x60W.  Then, I look at the datasheets of audio amplifier ICs, like the TPA3116 that says: &quot;50W into a 4Ω load at 21V&quot;, which makes me conclude that in that setting it'll output 14V maximum into the speaker, which I think makes sense. But then, I look at the datasheet of the TDA7294, and they talk about &quot;RMS Power&quot; and &quot;RMS Music Power&quot;, units which I couldn't find clear information about. Then, I look at home audio systems, like a Panasonic Stereo System I have which has &quot;9500 Watts P.M.P.O.&quot; written on the front. 9500W? That sounds stupidly high to me, but then I look again and it has 300W written on the back of it. If I'm correct, maybe a 1kW home stereo system could make sense, but a 2kW or greater one would not exist. So... Are my conclusions about  and the TPA3116 correct? Are my conclusions about audio equipment power correct? Are WattsPMPO, WattsRMS and RMSmusicpower, real useful units? Best way to migrate a huge SQL Server database with low downtime over network Problem definition  Our database server needs to be transferred to an other datacenter. It runs on Microsoft SQL Server 2012 Enterprise (64-bit) and contains two databases of about 2TB and 1TB.  Having little to no downtime for this would be ideal.  Workload  Those databases are used for a .NET website and are constantly getting updated.   Having it not available over the weekend would be acceptable though. The currently in use DB would remain the only one in use until the switch over to the new one.  That switch would ideally be made just by changing DNS entries to point to the new DB server while making sure the DB is not being updated.  Also, time taken by this operation does not really matter as long as the switch from one server to the other (downtime) is kept low.  Approaches considered   Backup and restore  This has been done in the past but involved a high downtime even though it was done through an internal network, so more efficiently than through Internet Log shipping  As far as I understand, this approach would minimize downtime by configuring a master/slave and transferring  an exact copy of the master DB to its slave being read only. As mentioned above, no access to the slave would be necessary and we just need a way to have a replica of the master DB without data corruption.   It also seems to be quite efficient in terms of resources utilization and wouldn't impact to much the master performance.   I might be wrong about this approach so feel free to correct me. Database mirroring  I'm not too aware of that approach but it seems like a valid option. No need to have real time sync and performance of the master is quite important so asynchronous would be the way to go if this approach were to be chosen. Other options?  That server runs directly on bare metal hardware so lower level solutions are unfortunately not an option. Maybe there is a better way to get this done?   Constraints  As described, those databases are quite big to the point they are hard to maintain but that's an other problem.  The versions of SQL Server will be the same (Microsoft SQL Server 2012 Enterprise 64-bit).  It will have to be transferred over network between two datacenters so most probably over Internet. Having disks sent from one site to the other for an initial sync is unfortunately not an option. Having some sort of security for the transfer would be ideal but we will do the best of this situation.  That should give a quite good overview of our needs for this task and hopefully some of you had to face that situation before.