0

I am new to java and wanted to know if they was a way to jump to a JFrame from a JOptionFrame this is my code so far:

public class Input {

 public static void main(String[] args) {
String choose;


choose = JOptionPane.showInputDialog("Create New\n 1. Customer\n 2. Invoice");

if(choose.equalsIgnoreCase("customer")|| choose =="1"){


}else if(choose.equalsIgnoreCase("invoice")|| choose =="2"){


}else return;

 } 
}
Alya'a Gamal
  • 5,624
  • 19
  • 34
user3464613
  • 115
  • 1
  • 3
  • 9
  • 2
    Could you please elaborate on what do you mean by jump? And don't use '==' for strings. Check this link : http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – Tanmay Patil Mar 26 '14 at 14:19

2 Answers2

0

Use equals() instead of ==

if (choose.equalsIgnoreCase("customer")||choose.equals("1")) {
        /// call customer JFrame here 
 } else if (choose.equalsIgnoreCase("invoice")||choose.equals("2")) {
        /// call invoice JFrame here 
 } 
Alya'a Gamal
  • 5,624
  • 19
  • 34
0

Don't use == to compare String, use .equals(), also to show the JFrame you want suppose that you have a CustomerJFrame extends JFrame you need to do:

if(choose.equalsIgnoreCase("customer") || choose.equals("1")){
    JFrame customerFrame = new CustomerJFrame();
    customerFrame.setVisible(true); // here how show your jframe.
}
Salah
  • 8,567
  • 3
  • 26
  • 43