Results 1 to 2 of 2
Thread: Doesn't recognize string value?
- 10-08-2012, 05:25 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 14
- Rep Power
- 0
Doesn't recognize string value?
Alright, so I was trying to code a simple command system but I ran into a problem along the way. I tried to do the code below. But even when commandBar was equal to exit it would print: Command Value: "exit". So I am not sure what I am doing wrong. Any help is appreciated. Thanks!
Java Code:public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed: " + e.getSource().toString()); if(e.getSource() == commandEnter){ String command = commandBar.getText(); if(command == "exit"){ dispose(); System.exit(0); }else{ System.out.println("Command not recognized"); System.out.println("Command Value: \""+command+"\"\n"); } }else if(e.getSource() == exit){ dispose(); System.exit(0); } }
- 10-08-2012, 05:32 AM #2
Member
- Join Date
- Oct 2012
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
String replaceAll doesn't work!!!
By danoc93 in forum New To JavaReplies: 3Last Post: 06-25-2012, 11:29 AM -
Nimbus LaF doesn't recognize javax.swing.JTable?
By rudeboy in forum AWT / SwingReplies: 10Last Post: 12-04-2011, 08:14 PM -
string prompt doesn't appear in showInputDialog
By saxophone in forum New To JavaReplies: 4Last Post: 04-01-2010, 10:05 PM -
String array for Choice, JOptionPane doesn't show
By themburu in forum Java AppletsReplies: 5Last Post: 05-29-2008, 01:10 PM -
(newbie) String doesn't compile?!
By jon80 in forum New To JavaReplies: 5Last Post: 04-09-2008, 08:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks