473,667 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why isnt my if statement working

8 New Member
Hi guys im not sure what i am doinf wrong but the if statement in the action performed is not working any ideas


Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.util.*;
  6. import java.text.*;
  7.  
  8. public class LenzHotel extends JFrame implements ActionListener
  9. {
  10.     DataInputStream output;
  11.     DataInputStream input;
  12.     //contruct components
  13.     JTextArea roomDisplay1 = new JTextArea();
  14.     JTextArea roomDisplay2 = new JTextArea();
  15.     JTextArea roomDisplay3 = new JTextArea();
  16.     JTextArea roomDisplay4 = new JTextArea();
  17.     JTextArea roomDisplay5 = new JTextArea();
  18.     JTextArea roomDisplay6 = new JTextArea();
  19.     JTextArea roomDisplay7 = new JTextArea();
  20.     JTextArea roomDisplay8 = new JTextArea();
  21.     JTextArea roomDisplay9 = new JTextArea();
  22.     JTextArea roomDisplay10 = new JTextArea();
  23.     JTextArea roomDisplay11 = new JTextArea();
  24.     JTextArea roomDisplay12 = new JTextArea();
  25.     JTextArea roomDisplay13 = new JTextArea();
  26.     JTextArea roomDisplay14 = new JTextArea();
  27.     JTextArea roomDisplay15 = new JTextArea();
  28.     JTextArea roomDisplay16 = new JTextArea();
  29.     JTextArea roomDisplay17 = new JTextArea();
  30.     JTextArea roomDisplay18 = new JTextArea();
  31.     JTextArea roomDisplay19 = new JTextArea();
  32.     JTextArea roomDisplay20 = new JTextArea();
  33.     JComboBox choice = new JComboBox();
  34.     JLabel name = new JLabel("Name");
  35.     JTextField nameField = new JTextField(15);
  36.     JLabel phone = new JLabel("Phone Number");
  37.     JTextField phoneField = new JTextField(15);
  38.     JLabel vehicle = new JLabel("Vehicle Registration Number");
  39.     JTextField vehicleField = new JTextField(15);
  40.     JLabel address = new JLabel("Customers address");
  41.     JTextField addressField = new JTextField(15);
  42.     JLabel checkin = new JLabel("Check in time and date");
  43.     JTextField checkinField = new JTextField(15);
  44.     JLabel business = new JLabel("Business or Overnight");
  45.     JTextField businessField = new JTextField(15);
  46.     JLabel tariff = new JLabel("Tariff");
  47.     JTextField tariffField = new JTextField(15);
  48.     JLabel deposit = new JLabel("Deposit");
  49.     JTextField depositField = new JTextField(15);
  50.     JLabel checkout = new JLabel("Check out Time and Date");
  51.     JTextField checkoutField = new JTextField(15);
  52.     JLabel choiceLabel = new JLabel("Clear which Field");
  53.     JComboBox smoking = new JComboBox();
  54.     JLabel bookLabel = new JLabel("Book which room");
  55.     JComboBox book = new JComboBox();
  56.     JButton bookButton = new JButton("Book room");
  57.  
  58.  
  59.  
  60.  
  61.     public LenzHotel()
  62.     {
  63.         super("Lenasia Hotel");
  64.     }
  65.  
  66.     public Container createContentPane()
  67.     {
  68.         JPanel bottomPanel = new JPanel();
  69.         bottomPanel.add(bookLabel);
  70.         bottomPanel.add(book);
  71.                 bottomPanel.add(choice);
  72.             book.addItem("1");
  73.             book.setActionCommand("one");
  74.             book.addItem("2");
  75.             book.setActionCommand("two");
  76.             book.addActionListener(this);
  77.             book.addItem("3");
  78.             book.setActionCommand("three");
  79.             book.addActionListener(this);
  80.             book.addItem("4");
  81.             book.setActionCommand("four");
  82.             book.addActionListener(this);
  83.             book.addItem("5");
  84.             book.setActionCommand("five");
  85.             book.addActionListener(this);
  86.             book.addItem("6");
  87.             book.setActionCommand("six");
  88.             book.addActionListener(this);
  89.             book.addItem("7");
  90.             book.setActionCommand("seven");
  91.             book.addActionListener(this);
  92.             book.addItem("8");
  93.             book.setActionCommand("eight");
  94.             book.addActionListener(this);
  95.             book.addItem("9");
  96.             book.setActionCommand("nine");
  97.             book.addActionListener(this);
  98.             book.addItem("10");
  99.             book.setActionCommand("ten");
  100.             book.addActionListener(this);
  101.             book.addItem("11");
  102.             book.setActionCommand("eleven");
  103.             book.addActionListener(this);
  104.             book.addItem("12");
  105.             book.setActionCommand("twelve");
  106.             book.addActionListener(this);
  107.             book.addItem("13");
  108.             book.setActionCommand("thirteen");
  109.             book.addActionListener(this);
  110.             book.addItem("14");
  111.             book.setActionCommand("fourteen");
  112.             book.addActionListener(this);
  113.             book.addItem("15");
  114.             book.setActionCommand("fifteen");
  115.             book.addActionListener(this);
  116.             book.addItem("sixteen");
  117.             book.setActionCommand("16");
  118.             book.addActionListener(this);
  119.             book.addItem("seventeen");
  120.             book.setActionCommand("17");
  121.             book.addActionListener(this);
  122.             book.addItem("eighteen");
  123.             book.setActionCommand("18");
  124.             book.addActionListener(this);
  125.             book.addItem("nineteen");
  126.             book.setActionCommand("19");
  127.             book.addActionListener(this);
  128.             book.addItem("20");
  129.             book.setActionCommand("twenty");
  130.             book.addActionListener(this);
  131.  
  132.         bottomPanel.add(bookButton);
  133.         bookButton.addActionListener(this);
  134.  
  135.         bottomPanel.add(choiceLabel);
  136.         bottomPanel.add(choice);
  137.             choice.addItem("1");
  138.             choice.setActionCommand("1");
  139.             choice.addActionListener(this);
  140.             choice.addItem("2");
  141.             choice.setActionCommand("2");
  142.             choice.addActionListener(this);
  143.             choice.addItem("3");
  144.             choice.setActionCommand("3");
  145.             choice.addActionListener(this);
  146.             choice.addItem("4");
  147.             choice.setActionCommand("4");
  148.             choice.addActionListener(this);
  149.             choice.addItem("5");
  150.             choice.setActionCommand("5");
  151.             choice.addActionListener(this);
  152.             choice.addItem("6");
  153.             choice.setActionCommand("6");
  154.             choice.addActionListener(this);
  155.             choice.addItem("7");
  156.             choice.setActionCommand("7");
  157.             choice.addActionListener(this);
  158.             choice.addItem("8");
  159.             choice.setActionCommand("8");
  160.             choice.addActionListener(this);
  161.             choice.addItem("9");
  162.             choice.setActionCommand("9");
  163.             choice.addActionListener(this);
  164.             choice.addItem("10");
  165.             choice.setActionCommand("10");
  166.             choice.addActionListener(this);
  167.             choice.addItem("11");
  168.             choice.setActionCommand("11");
  169.             choice.addActionListener(this);
  170.             choice.addItem("12");
  171.             choice.setActionCommand("12");
  172.             choice.addActionListener(this);
  173.             choice.addItem("13");
  174.             choice.setActionCommand("13");
  175.             choice.addActionListener(this);
  176.             choice.addItem("14");
  177.             choice.setActionCommand("14");
  178.             choice.addActionListener(this);
  179.             choice.addItem("15");
  180.             choice.setActionCommand("15");
  181.             choice.addActionListener(this);
  182.             choice.addItem("16");
  183.             choice.setActionCommand("16");
  184.             choice.addActionListener(this);
  185.             choice.addItem("17");
  186.             choice.setActionCommand("17");
  187.             choice.addActionListener(this);
  188.             choice.addItem("18");
  189.             choice.setActionCommand("18");
  190.             choice.addActionListener(this);
  191.             choice.addItem("19");
  192.             choice.setActionCommand("19");
  193.             choice.addActionListener(this);
  194.             choice.addItem("20");
  195.             choice.setActionCommand("20");
  196.             choice.addActionListener(this);
  197.  
  198.  
  199.  
  200.  
  201.         JPanel northPanel = new JPanel();
  202.         northPanel.setLayout(new GridLayout(5,4,10,10));
  203.         northPanel.add(roomDisplay1);
  204.         roomDisplay1.setColumns(5);
  205.         roomDisplay1.setRows(5);
  206.         roomDisplay1.setLineWrap(true);
  207.         roomDisplay1.setBackground(Color.green);
  208.         roomDisplay1.setText("Room 1");
  209.         roomDisplay1.setEditable(false);
  210.         JScrollPane scrollPane1 = new JScrollPane(roomDisplay1);
  211.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  212.             scrollPane1.setPreferredSize(new Dimension(30,30));
  213.         northPanel.add(scrollPane1);
  214.         northPanel.add(roomDisplay2);
  215.         roomDisplay2.setColumns(5);
  216.         roomDisplay2.setRows(5);
  217.         roomDisplay2.setLineWrap(true);
  218.         roomDisplay2.setText("Room 2");
  219.         roomDisplay2.setEditable(false);
  220.         roomDisplay2.setBackground(Color.green);
  221.         JScrollPane scrollPane2 = new JScrollPane(roomDisplay2);
  222.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  223.             scrollPane1.setPreferredSize(new Dimension(30,30));
  224.         northPanel.add(scrollPane2);
  225.         northPanel.add(roomDisplay3);
  226.         roomDisplay3.setColumns(5);
  227.         roomDisplay3.setRows(5);
  228.         roomDisplay3.setLineWrap(true);
  229.         roomDisplay3.setText("Room 3");
  230.         roomDisplay3.setEditable(false);
  231.         roomDisplay3.setBackground(Color.green);
  232.         JScrollPane scrollPane3 = new JScrollPane(roomDisplay3);
  233.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  234.             scrollPane1.setPreferredSize(new Dimension(30,30));
  235.         northPanel.add(scrollPane3);
  236.         northPanel.add(roomDisplay4);
  237.         roomDisplay4.setColumns(5);
  238.         roomDisplay4.setRows(5);
  239.         roomDisplay4.setLineWrap(true);
  240.         roomDisplay4.setText("Room 4");
  241.         roomDisplay4.setEditable(false);
  242.         roomDisplay4.setBackground(Color.green);
  243.         JScrollPane scrollPane4 = new JScrollPane(roomDisplay4);
  244.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  245.             scrollPane1.setPreferredSize(new Dimension(30,30));
  246.         northPanel.add(scrollPane4);
  247.         northPanel.add(roomDisplay5);
  248.         roomDisplay5.setColumns(5);
  249.         roomDisplay5.setRows(5);
  250.         roomDisplay5.setLineWrap(true);
  251.         roomDisplay5.setText("Room 5");
  252.         roomDisplay5.setEditable(false);
  253.         roomDisplay5.setBackground(Color.green);
  254.         JScrollPane scrollPane5 = new JScrollPane(roomDisplay5);
  255.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  256.             scrollPane1.setPreferredSize(new Dimension(30,30));
  257.         northPanel.add(scrollPane5);
  258.         northPanel.add(roomDisplay6);
  259.         roomDisplay6.setColumns(5);
  260.         roomDisplay6.setRows(5);
  261.         roomDisplay6.setLineWrap(true);
  262.         roomDisplay6.setText("Room 6");
  263.         roomDisplay6.setEditable(false);
  264.         roomDisplay6.setBackground(Color.green);
  265.         JScrollPane scrollPane6 = new JScrollPane(roomDisplay6);
  266.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  267.             scrollPane1.setPreferredSize(new Dimension(30,30));
  268.         northPanel.add(scrollPane6);
  269.         northPanel.add(roomDisplay7);
  270.         roomDisplay7.setColumns(5);
  271.         roomDisplay7.setRows(5);
  272.         roomDisplay7.setLineWrap(true);
  273.         roomDisplay7.setText("Room 7");
  274.         roomDisplay7.setEditable(false);
  275.         roomDisplay7.setBackground(Color.green);
  276.         JScrollPane scrollPane7 = new JScrollPane(roomDisplay7);
  277.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  278.             scrollPane1.setPreferredSize(new Dimension(30,30));
  279.         northPanel.add(scrollPane7);
  280.         northPanel.add(roomDisplay8);
  281.         roomDisplay8.setText("Room 8");
  282.         roomDisplay8.setColumns(5);
  283.         roomDisplay8.setRows(5);
  284.         roomDisplay8.setLineWrap(true);
  285.         roomDisplay8.setEditable(false);
  286.         roomDisplay8.setBackground(Color.green);
  287.         JScrollPane scrollPane8 = new JScrollPane(roomDisplay8);
  288.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  289.             scrollPane1.setPreferredSize(new Dimension(30,30));
  290.         northPanel.add(scrollPane8);
  291.         northPanel.add(roomDisplay9);
  292.         roomDisplay9.setColumns(5);
  293.         roomDisplay9.setRows(5);
  294.         roomDisplay9.setLineWrap(true);
  295.         roomDisplay9.setText("Room 9");
  296.         roomDisplay9.setEditable(false);
  297.         roomDisplay9.setBackground(Color.green);
  298.         JScrollPane scrollPane9 = new JScrollPane(roomDisplay9);
  299.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  300.             scrollPane1.setPreferredSize(new Dimension(30,30));
  301.         northPanel.add(scrollPane9);
  302.         northPanel.add(roomDisplay10);
  303.         roomDisplay10.setColumns(5);
  304.         roomDisplay10.setRows(5);
  305.         roomDisplay10.setLineWrap(true);
  306.         roomDisplay10.setText("Room 10");
  307.         roomDisplay10.setEditable(false);
  308.         roomDisplay10.setBackground(Color.green);
  309.         JScrollPane scrollPane10 = new JScrollPane(roomDisplay10);
  310.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  311.             scrollPane1.setPreferredSize(new Dimension(30,30));
  312.         northPanel.add(scrollPane10);
  313.         northPanel.add(roomDisplay11);
  314.         roomDisplay11.setColumns(5);
  315.         roomDisplay11.setRows(5);
  316.         roomDisplay11.setLineWrap(true);
  317.         roomDisplay11.setText("Room 11");
  318.         roomDisplay11.setEditable(false);
  319.         roomDisplay11.setBackground(Color.green);
  320.         JScrollPane scrollPane11 = new JScrollPane(roomDisplay11);
  321.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  322.             scrollPane1.setPreferredSize(new Dimension(30,30));
  323.         northPanel.add(scrollPane11);
  324.         northPanel.add(roomDisplay12);
  325.         roomDisplay12.setColumns(5);
  326.         roomDisplay12.setRows(5);
  327.         roomDisplay12.setLineWrap(true);
  328.         roomDisplay12.setText("Room 12");
  329.         roomDisplay12.setEditable(false);
  330.         roomDisplay12.setBackground(Color.green);
  331.         JScrollPane scrollPane12 = new JScrollPane(roomDisplay12);
  332.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  333.             scrollPane1.setPreferredSize(new Dimension(30,30));
  334.         northPanel.add(scrollPane12);
  335.         northPanel.add(roomDisplay13);
  336.         roomDisplay13.setColumns(5);
  337.         roomDisplay13.setRows(5);
  338.         roomDisplay13.setLineWrap(true);
  339.         roomDisplay13.setText("Room 13");
  340.         roomDisplay13.setEditable(false);
  341.         roomDisplay13.setBackground(Color.green);
  342.         JScrollPane scrollPane13 = new JScrollPane(roomDisplay13);
  343.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  344.             scrollPane1.setPreferredSize(new Dimension(30,30));
  345.         northPanel.add(scrollPane13);
  346.         northPanel.add(roomDisplay14);
  347.         roomDisplay14.setColumns(5);
  348.         roomDisplay14.setRows(5);
  349.         roomDisplay14.setLineWrap(true);
  350.         roomDisplay14.setText("Room 14");
  351.         roomDisplay14.setEditable(false);
  352.         roomDisplay14.setBackground(Color.green);
  353.         JScrollPane scrollPane14 = new JScrollPane(roomDisplay14);
  354.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  355.             scrollPane1.setPreferredSize(new Dimension(30,30));
  356.         northPanel.add(scrollPane14);
  357.         northPanel.add(roomDisplay15);
  358.         roomDisplay15.setColumns(5);
  359.         roomDisplay15.setRows(5);
  360.         roomDisplay15.setLineWrap(true);
  361.         roomDisplay15.setText("Room 15");
  362.         roomDisplay15.setEditable(false);
  363.         roomDisplay15.setBackground(Color.green);
  364.         JScrollPane scrollPane15 = new JScrollPane(roomDisplay15);
  365.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  366.             scrollPane1.setPreferredSize(new Dimension(30,30));
  367.         northPanel.add(scrollPane15);
  368.         northPanel.add(roomDisplay16);
  369.         roomDisplay16.setColumns(5);
  370.         roomDisplay16.setRows(5);
  371.         roomDisplay16.setLineWrap(true);
  372.         roomDisplay16.setText("Room 16");
  373.         roomDisplay16.setEditable(false);
  374.         roomDisplay16.setBackground(Color.green);
  375.         JScrollPane scrollPane16 = new JScrollPane(roomDisplay16);
  376.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  377.             scrollPane1.setPreferredSize(new Dimension(30,30));
  378.         northPanel.add(scrollPane16);
  379.         northPanel.add(roomDisplay17);
  380.         roomDisplay17.setColumns(5);
  381.         roomDisplay17.setRows(5);
  382.         roomDisplay17.setLineWrap(true);
  383.         roomDisplay17.setText("Room 17");
  384.         roomDisplay17.setEditable(false);
  385.         roomDisplay17.setBackground(Color.green);
  386.         JScrollPane scrollPane17 = new JScrollPane(roomDisplay17);
  387.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  388.             scrollPane1.setPreferredSize(new Dimension(30,30));
  389.         northPanel.add(scrollPane17);
  390.         northPanel.add(roomDisplay18);
  391.         roomDisplay18.setColumns(5);
  392.         roomDisplay18.setRows(5);
  393.         roomDisplay18.setLineWrap(true);
  394.         roomDisplay18.setText("Room 18");
  395.         roomDisplay18.setEditable(false);
  396.         roomDisplay18.setBackground(Color.green);
  397.         JScrollPane scrollPane18 = new JScrollPane(roomDisplay18);
  398.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  399.             scrollPane1.setPreferredSize(new Dimension(30,30));
  400.         northPanel.add(scrollPane18);
  401.         northPanel.add(roomDisplay19);
  402.         roomDisplay19.setColumns(5);
  403.         roomDisplay19.setRows(5);
  404.         roomDisplay19.setLineWrap(true);
  405.         roomDisplay19.setText("Room 19");
  406.         roomDisplay19.setEditable(false);
  407.         roomDisplay19.setBackground(Color.green);
  408.         JScrollPane scrollPane19 = new JScrollPane(roomDisplay19);
  409.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  410.             scrollPane1.setPreferredSize(new Dimension(30,30));
  411.         northPanel.add(scrollPane19);
  412.         northPanel.add(roomDisplay20);
  413.         roomDisplay20.setColumns(5);
  414.         roomDisplay20.setRows(5);
  415.         roomDisplay20.setLineWrap(true);
  416.         roomDisplay20.setText("Room 20");
  417.         roomDisplay20.setEditable(false);
  418.         roomDisplay20.setBackground(Color.green);
  419.         JScrollPane scrollPane20 = new JScrollPane(roomDisplay20);
  420.             scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  421.             scrollPane1.setPreferredSize(new Dimension(30,30));
  422.         northPanel.add(scrollPane20);
  423.  
  424.  
  425.                 JPanel centerPanel = new JPanel();
  426.                 centerPanel.setLayout(new GridLayout(3,6,10,10));
  427.                 centerPanel.add(name);
  428.                 centerPanel.add(nameField);
  429.                 centerPanel.add(phone);
  430.                 centerPanel.add(phoneField);
  431.                 centerPanel.add(vehicle);
  432.                 centerPanel.add(vehicleField);
  433.                 centerPanel.add(address);
  434.                 centerPanel.add(addressField);
  435.                 centerPanel.add(checkin);
  436.                 centerPanel.add(checkinField);
  437.                 centerPanel.add(business);
  438.                 centerPanel.add(businessField);
  439.                 centerPanel.add(tariff);
  440.                 centerPanel.add(tariffField);
  441.                 centerPanel.add(deposit);
  442.                 centerPanel.add(depositField);
  443.                 centerPanel.add(checkout);
  444.                 centerPanel.add(checkoutField);
  445.  
  446.  
  447.  
  448.         Container c = getContentPane();
  449.             c.setLayout(new BorderLayout(10,10));
  450.             c.add(northPanel,BorderLayout.NORTH);
  451.             c.add(centerPanel,BorderLayout.CENTER);
  452.             c.add(bottomPanel,BorderLayout.SOUTH);
  453.         return c;
  454.  
  455.     }//end of container pane
  456.  
  457.     public void actionPerformed(ActionEvent e)
  458.     {
  459.         String arg = e.getActionCommand();
  460.         if(arg == "1")
  461.         {
  462.                     roomDisplay1.setBackground(Color.red);
  463.                     roomDisplay1.setText("Room 1"+"\nName: "+
  464.                                     nameField.getText()+"\nPhone number: "+
  465.                                     phoneField.getText()+"\nVehicle registration number: "+
  466.                                     vehicleField.getText()+"\nCustomers address: "+
  467.                                     addressField.getText()+"\nCheck in: "+
  468.                                     checkinField.getText()+"\nType of stay: "+
  469.                                     businessField.getText()+"\nTariff: "+
  470.                                     tariffField.getText()+"\nDeposit: "+
  471.                                     depositField.getText()+"\nCheckout: "+
  472.                                     checkoutField.getText()
  473.                                 );
  474.         }
  475.     }
  476.  
  477.  
  478.     public static void main(String[] args)
  479.     {
  480.         JFrame.setDefaultLookAndFeelDecorated(true);
  481.         LenzHotel f = new LenzHotel();
  482.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  483.         f.setContentPane(f.createContentPane());
  484.         f.setSize(700,500);
  485.         f.setVisible(true);
  486.     }//end of main method
  487. }//end of main costructor method
  488.  
Oct 18 '08 #1
4 2269
JosAH
11,448 Recognized Expert MVP
Hi guys im not sure what i am doinf wrong but the if statement in the action performed is not working any ideas
You don't compare Strings by using the == operator; you did this:

Expand|Select|Wrap|Line Numbers
  1.         if(arg == "1")
This only checks whether or not arg is identical to "1" and most likely it isn't.
It can only point to another string having the content "1" but seldom to the
literal String "1".

If you want to compare Strings for having equal content you have to do this:

Expand|Select|Wrap|Line Numbers
  1. if (arg.equals("1"))
Also read the API documentation for the String class. Remember: only primitives
(int, long, double etc) can be compared for equality of content by using the ==
opererators; class objects have the equals() method for that.

kind regards,

Jos
Oct 18 '08 #2
Badboy112
8 New Member
You don't compare Strings by using the == operator; you did this:

Expand|Select|Wrap|Line Numbers
  1.         if(arg == "1")
This only checks whether or not arg is identical to "1" and most likely it isn't.
It can only point to another string having the content "1" but seldom to the
literal String "1".

If you want to compare Strings for having equal content you have to do this:

Expand|Select|Wrap|Line Numbers
  1. if (arg.equals("1"))
Also read the API documentation for the String class. Remember: only primitives
(int, long, double etc) can be compared for equality of content by using the ==
opererators; class objects have the equals() method for that.

kind regards,

Jos

Hi jos

This is the error message im getting

G:\LenzHotel.ja va:460: cannot resolve symbol
symbol : method eqauls (java.lang.Stri ng)
location: class java.lang.Strin g
if(arg.eqauls(" one"))
^
1 error

Tool completed with exit code 1
Oct 18 '08 #3
JosAH
11,448 Recognized Expert MVP
Hi jos

This is the error message im getting

G:\LenzHotel.ja va:460: cannot resolve symbol
symbol : method eqauls (java.lang.Stri ng)
location: class java.lang.Strin g
if(arg.eqauls(" one"))
^
1 error

Tool completed with exit code 1
You can spell ;-)

kind regards,

Jos
Oct 18 '08 #4
Badboy112
8 New Member
You can spell ;-)

kind regards,

Jos
lol
(ARGS)

thanx man
Oct 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3062
by: mirandacascade | last post by:
O/S: Windows 2K Vsn of Python: 2.4 Currently: 1) Folder structure: \workarea\ <- ElementTree files reside here \xml\ \dom\
7
11433
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And #11/2/2003# And VehicleID='00000000' And BattID='LKO500HF'. I need to use the records returned to populate text boxes, but the data requires further manipulation. I attempting to use expressions in the control source
3
4609
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using Access 97 (I know it's old. But, it's the tool they give me to work with) My working knowledge of SQL is on the low side. My working knowledge of VBA is beginner.
3
1244
by: Abubakar | last post by:
HI all, working in the vs.net 2k5 beta 2, I write the following code which gives me an exception: ContextMenu textboxmenu = textBox2.ContextMenu; MenuItem menuitem = new MenuItem("hello"); textboxmenu.MenuItems.Add(0,menuitem); its gives me an exception: "Object reference not set to an instance of an object.". I understand this msg but its not so, cuz the variable "menuitem"
5
3979
by: Jon via DotNetMonster.com | last post by:
<siteMapNode title="share price" description="Link to Netcall on the London Stock Exchange" url="http://www.yahoo.co.uk" role="" target="_blank" /> Hi all I'm trying to open the Yahoo web site in a new window using the above code in my asp.net web.sitemap. I'm expecting the target="_blank" bit to make it do this. but it isnt. Does anyone know why?? Thanks in advance.
14
3090
by: Matt | last post by:
I need to add the following variable into an SQL statement and not sure how to do it. strGCID needs to be inserted into the following statement: SQL = "SELECT tblContacts.* FROM tblContacts INNER JOIN tblGC ON tblContacts.GCID = tblGC.gcID WHERE (((tblContacts.GCID)=strGCID))" i am just not sure of the proper syntax.
2
544
by: iulian.ilea | last post by:
What is wrong int this SQL statement? select top 10 DOCInt.*, DOCDet.* , Cate.*, Arti.*, .* from DOCInt INNER JOIN DOCDet ON DOCInt.CodDoc=DOCDet.CodDoc LEFT JOIN Cate ON DOCDet.IDCategory=Cate. LEFT JOIN Arti ON DOCDet.IDArti=Arti. INNER JOIN ON DOCInt.IDAnag=. GROUP BY DOCInt.IDDoc
1
2016
by: kellysgirl | last post by:
Step 3 – Add code in the Form’s Load event to select the first radio button: In the Form’s Load event, write code to select the Comma choice in the radio buttons group box. Step 4 – Add code in the Parse Text to List button’s Click event to parse and load the list box: You will need the variables shown in Table 1: Variable name Type Use delimiter String Holds the String character representing the chosen delimiter ...
7
2890
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt enough memory' error whenever I scroll past N number of bytes in a textbox that has been filled with a lot of data. I am not sure what N is, but for a large chunk of data it occurs at about the halfway scroll, and smaller chunks might not throw...
0
8457
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8646
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.