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 :(
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?
Java String split is not working var functionName = function() {} vs function functionName() {} Japan is a volcanically active country which means it has a plethora of onsen (hot springs) all around the country.  Visiting these onsen is supposed to be a popular vacation destination for the work-weary Japanese.    I've been told that, as with other things in Japan, there is a rather strict etiquette surrounding the use of the onsen.  In particular, the two things I've read about so far are   Swimming Suits are not allowed. It is very important that one bathe immediately before entering the onsen.   Are these true?  Are there any other taboos that a naive American should be aware of? GPU Rendering causing strange lines When I render using my r9 390 graphics card, weird lines are appearing over the render. This problem has just started happening recently, as a few days ago I was rendering the same scene without the lines appearing. I don't believe I've changed any settings in Blender and the below scene is from a new file, so render settings should be default.   Rendering using my CPU is fine:   The only thing I can think that has changed is I recently updated my card to the latest drivers. Playing games with it is still fine and the card is quite new so I wouldn't think it's a problem with the card itself. How to disable Macbook Pro internal display when using external monitors I have a Late 2011 Macbook Pro 13" (running Lion - OS 10.7.4) which I use with a dual external monitor setup. I have two 21" LCDs that I use as external monitors. One uses the built in Mini Display Port on the Macbook Pro and the other is connected via a USB to DVI adapter (Diamond DVILink).  The problem I am having is with the 13" built in display of the Macbook Pro. I would like it to remain closed and unused (I prefer the dual monitors at same resolution), however I cannot seem to "disable" the display in the display preferences applet. So even though the Macbook Pro lid is closed the operating system still makes use of the display, even though the apple logo on the back of the display is unlit. I have tried to move the laptop screen off out of the way in display preferences but I find when I "sleep" my setup that any applications that remain open move to the laptop screen. This makes it difficult to locate the application windows when resuming from sleep.    Does anyone know of a way to disable the laptop built in display so it is not seen by the OS when external monitors are being used? How do I check if an element is really visible with JavaScript? In JavaScript, how would you check if an element is actually visible?  I don't just mean checking the visibility and display attributes. I mean, checking that the element is not   visibility: hidden or display: none underneath another element scrolled off the edge of the screen   For technical reasons I can't include any scripts. I can however use  as it is on the page already. This is a follow-up to this question:   Hans Bethe wrote a paper in 1944, "Theory of Diffraction by Small Holes," Phys. Rev. 66, 163. I don't have access to the paper, but from descriptions online it sounds like he proved the following. Suppose a plane wave impinges on an absorbing sheet, and there is a hole in the sheet of diameter $d$, with $d&lt;\lambda$. Let $P_0$ be the power incident on the hole, and $P$ the power diffracted through the hole. Then the transmission is $T=P/P_0=(d/\lambda)^4$.  As a practical application, I think this explains why microwaves don't leak strongly through the metal grille in the front of a microwave oven.  Questions:   Does the thickness of the sheet matter? From references online, it sounds like the hole is treated as a waveguide...? This seems to relate to cutoff frequencies of waveguides, etc.? It seems to me that Huygens' principle would give $T=1$ for $d\ll\lambda$, since in this limit the wavelets are in phase. Why is Huygens' principle invalid here? Is this related to question #1? Is there a simple argument for the proportionality to $(d/\lambda)^4$? Or if not, how does one prove this using the gory details of Bessel functions, etc.? If someone else is booking international ticket for me using his credit or debit card, does he need to be present physically at the time of check-in?   Suppose I am coming back from Singapore to my home country and my ticket is booked by my friend for me, who lives in my home country. Do airlines in Singapore ask for the person to be present physically to check in? How do I complete "Find the Bitizen"? In tiny Death Star, Palpatine has given me the mission "Find the Bitizen" with the text "Working for tips is acceptable. Find 1 Bitizen(s)."  I assumed I had to wait for one of the events where you have to find a "rebel scum" and tap on it to get rid of. One of those events finally popped up but it did not complete the mission.   How do I complete this mission? Creating Indexes on DB with Hibernate @Index Annotation Why is $1^{\infty}$ considered to be an indeterminate form From : In calculus and other branches of mathematical analysis, an indeterminate form is an algebraic expression obtained in the context of limits. Limits involving algebraic operations are often performed by replacing subexpressions by their limits; if the expression obtained after this substitution does not give enough information to determine the original limit, it is known as an indeterminate form.    The indeterminate forms include $0^{0},\frac{0}{0},(\infty - \infty),1^{\infty}, \ \text{etc}\cdots$   My question is can anyone give me a nice explanation of why $1^{\infty}$ is considered to be an indeterminate form? Because, i don't see any justification of this fact. I am still perplexed. If I press the "include alpha-button" in the Mix-Color-Node, I get white borders. Otherwise i've got a perfect alpha but no blue background. Do I need to change my ESTA address when visiting the US? I have an ESTA for my visit last Sept to NY and I know it is valid for 2years.  I am going to Las Vegas in May, do I have to update the address at which I will be staying? When should I use GET or POST method? What's the difference between them? I have a significant three-way interaction (with no significant two-way interactions and no significant main effects).  To begin with I have followed this up with two two-way ANOVAs (one at each level of the third variable). The first part of my question is whether this is an appropriate follow-up.  This showed no significant main effects or interactions at either level of the third variable...is this the end of the analysis?  If so, how would I interpret the three-way interaction? How to parse data in JSON format? Tentative definitions in C and linking Combination with repetitions. Is it ok to say 'sorry' where you otherwise would use 'excuse me'?  Example: "Sorry, but could you show me the way to the next train station?" I want to leave my Mac awake overnight so it syncs 4GB of data from Dropbox. I need to prevent the machine from going to sleep because that pauses the Dropbox sync  I've been using  to keep the computer awake, but it also keeps the computer unlocked which is insecure.  I need a method to keep my Mac awake (so that Dropbox can sync overnight) but also locked (so no one can read my email). It'd be great if this method also turned off the screen (to preserve power), but honestly that's not even 100% necessary.