Results 1 to 11 of 11

Thread: GUI Phone

  1. #1
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Question GUI Phone

    hi,
    i suppose to make simulation to cellphone. when press any digit ,it should appears on the display textfield to form a complete number. and when press the send button a message with"redialling+ the gigits pressed" appears on the textfield also when press redial button a message with " redialling+ the digits being pressed" appears on the textfield. but i have many errors as the following:

    CellPhone.java:228: <identifier> expected
    Button1.addActionListener(listener);
    ^
    CellPhone.java:228: <identifier> expected
    Button1.addActionListener(listener);
    ^
    CellPhone.java:229: <identifier> expected
    Button2.addActionListener(listener);
    ^
    CellPhone.java:229: <identifier> expected
    Button2.addActionListener(listener);
    ^
    CellPhone.java:230: <identifier> expected
    Button3.addActionListener(listener);
    ^
    CellPhone.java:230: <identifier> expected
    Button3.addActionListener(listener);
    ^
    CellPhone.java:231: <identifier> expected
    Button4.addActionListener(listener);
    ^
    CellPhone.java:231: <identifier> expected
    Button4.addActionListener(listener);
    ^
    CellPhone.java:232: <identifier> expected
    Button5.addActionListener(listener);
    ^
    CellPhone.java:232: <identifier> expected
    Button5.addActionListener(listener);
    ^
    CellPhone.java:233: <identifier> expected
    Button6.addActionListener(listener);
    ^
    CellPhone.java:233: <identifier> expected
    Button6.addActionListener(listener);
    ^
    CellPhone.java:234: <identifier> expected
    Button7.addActionListener(listener);
    ^
    CellPhone.java:234: <identifier> expected
    Button7.addActionListener(listener);
    ^
    CellPhone.java:235: <identifier> expected
    Button8.addActionListener(listener);
    ^
    CellPhone.java:235: <identifier> expected
    Button8.addActionListener(listener);
    ^
    CellPhone.java:236: <identifier> expected
    Button9.addActionListener(listener);
    ^
    CellPhone.java:236: <identifier> expected
    Button9.addActionListener(listener);
    ^
    CellPhone.java:237: <identifier> expected
    Button0.addActionListener(listener);
    ^
    CellPhone.java:237: <identifier> expected
    Button0.addActionListener(listener);
    ^
    CellPhone.java:238: <identifier> expected
    astrButton.addActionListener(listener);
    ^
    CellPhone.java:238: <identifier> expected
    astrButton.addActionListener(listener);
    ^
    CellPhone.java:239: <identifier> expected
    boundButton.addActionListener(listener);
    ^
    CellPhone.java:239: <identifier> expected
    boundButton.addActionListener(listener);
    ^
    CellPhone.java:279: reached end of file while parsing
    }
    ^
    CellPhone.java:286: reached end of file while parsing

    ^:confused:

    Java Code:
    /** 
      This program simulates a cellphone.
    
    */
    
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    
    public class CellPhone extends JFrame {
    
    	private final String WINDOW_TITLE = "CellPhone Simulation";
    	private final int WINDOW_WIDTH = 200; 
    	private final int WINDOW_HEIGHT = 300; 
    
    	
    
    	// The following named controls will appear in our GUI
    
        private JPanel textPanel = new JPanel();
        private JPanel digitPanel = new JPanel();
        private JPanel buttonPanel = new JPanel();
    
        
        private JLabel displayLabel = new JLabel ("                     NOKIA ");
    
        private JTextField displayTextField = new JTextField(20);
        
        private JButton sendButton = new JButton("Send");
        private JButton clearButton = new JButton("Clear");
        private JButton endButton = new JButton("End ");
        private JButton redialButton = new JButton("Redial");
        private JButton Button1 = new JButton("1");
        private JButton Button2 = new JButton("2");
        private JButton Button3 = new JButton("3");
        private JButton Button4 = new JButton("4");
        private JButton Button5 = new JButton("5");
        private JButton Button6 = new JButton("6");
        private JButton Button7 = new JButton("7");
        private JButton Button8 = new JButton("8");
        private JButton Button9 = new JButton("9");
        private JButton Button0 = new JButton("0");
        private JButton astrButton = new JButton("*");
        private JButton boundButton = new JButton("#");
        
    /** We'll use DecimalFormat later to convert the result to a String with two decimal places.
     */
    
        private DecimalFormat df2 = new DecimalFormat("#,###.00");
    
        /**
          The main method creates an instance of the cellphone class, which displays
          its window on the screen.
        */
    
        public static void main(String[] args) {
            new CellPhone();
        }
    
    /**
        The constructor for this application will initialize the JFrame
        by setting the window title bar, giving the frame a size,
        initializing all the controls that appear on the frame, and
        then make it visible.
     */
        public CellPhone()
        {
    
            setTitle(WINDOW_TITLE);
            setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            buildTextPanel();
            buildButtonPanel();
            buildDigitPanel();
            setLayout(new BorderLayout());
            add(textPanel,BorderLayout.NORTH);
            add(buttonPanel,BorderLayout.CENTER);
            add(digitPanel,BorderLayout.SOUTH);
            clearDisplay();
            setVisible(true);
    
        }
    
    /**
        The buildTextPanel method creates a panel to hold the label and the textfield.
     */
    	public void buildTextPanel () {
    		textPanel.setLayout(new BorderLayout());
    		textPanel.add(displayLabel,BorderLayout.NORTH);
    		textPanel.add(displayTextField,BorderLayout.CENTER);
                    textPanel.setBackground(Color.RED);
    	}
    
    /**
          The buildButtonPanel method creates a panel to hold the send,clear,end and redial buttons.
     */
    	public void buildButtonPanel () {
    		buttonPanel.setLayout(new FlowLayout());
    		buttonPanel.add(sendButton);
    		buttonPanel.add(clearButton);
    		buttonPanel.add(endButton);
                    buttonPanel.add(redialButton);
    		sendButton.addActionListener(new SendButtonListener());
    		clearButton.addActionListener(new ClearButtonListener());
    		endButton.addActionListener(new EndButtonListener());
                    redialButton.addActionListener(new RedialButtonListener());
                    buttonPanel.setBackground(Color.RED);
    	}
    
    /**
          The buildDigitPanel method creates a panel to hold the digit buttons.
     */
    	public void buildDigitPanel () {
    		digitPanel.setLayout(new GridLayout(3,4));
    		digitPanel.add(Button1);
    		digitPanel.add(Button2);
                    digitPanel.add(Button3);
                    digitPanel.add(Button4);
                    digitPanel.add(Button5);
                    digitPanel.add(Button6);
                    digitPanel.add(Button7);
                    digitPanel.add(Button8);
                    digitPanel.add(Button9);
                    digitPanel.add(Button0);
                    digitPanel.add(astrButton);
                    digitPanel.add(boundButton);
    	}
    
    
    
    /**
          SendButtonListener is an action listener class for
          the Send button.
     */
    
    	private class SendButtonListener implements ActionListener {
    /**
          The actionPerformed method executes when the user clicks on the send button.
          @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
    	       	sendCalling();
    		}
    	}
    
    /**
         ClearButtonListener is an action listener class for
          the Clear button.
     */
    
    	private class ClearButtonListener implements ActionListener {
    
    /**
         The actionPerformed method executes when the user clicks on the clear button.
          @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
    	       	clearDisplay();
    		}
    	}
    
    /**
        EndButtonListener is an action listener class for the Exit button.
     */
    
    	private class EndButtonListener implements ActionListener {
    /**
        The actionPerformed method executes when the user
         clicks on the end button.
         @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
    	       	endCalling();
    		}
    	}
    
            private class RedialButtonListener implements ActionListener {
    
            public void actionPerformed(ActionEvent e) {
                     redialCalling();
                     }
            }
    
       	
    /**
        The clearDisplay method will clear the digit,send,end and redial fields.
     */
    
       	public void clearDisplay() {
    		displayTextField.setText(" ");
    		
    	}
       	
    /**
        The sendCalling method will dislay a message when calling.
     */
            public void sendCalling() {
    		displayTextField.setText("Calling 000-000-0000");
    		
    	}
    /**
        The endCalling method will dislay a message when call is ended.
     */
            public void endCalling() {
    		displayTextField.setText("Call Ended");
    		
    	}
    /**
        The redialCalling method will dislay a message when number is redialing.
     */
            public void redialCalling() {
    		displayTextField.setText("Redialing 000-000-0000");
    		
    	}
    
    /** create innerlistener to all buttons, then add all buttons to 
        this listener. 
     */
            InnerListener listener= new InnerListener();
            Button1.addActionListener(listener);
            Button2.addActionListener(listener);
            Button3.addActionListener(listener);
            Button4.addActionListener(listener);
            Button5.addActionListener(listener);
            Button6.addActionListener(listener);
            Button7.addActionListener(listener);
            Button8.addActionListener(listener);
            Button9.addActionListener(listener);
            Button0.addActionListener(listener);
            astrButton.addActionListener(listener);
            boundButton.addActionListener(listener);
            
            private class InnerListener implements ActionListener {
    
            public void actionPerformed(ActionEvent e) {
                     if(e.getSource()==Button1) {
                        displayTextField.setText("1"); 
                      }
                       else if (e.getSource()==Button2) {
                         displayTextField.setText("2"); 
                       }
                       else if (e.getSource()==Button3) {
                         displayTextField.setText("3"); 
                       }
                       else if (e.getSource()==Button4) {
                         displayTextField.setText("4"); 
                       }
                       else if (e.getSource()==Button5) {
                         displayTextField.setText("5"); 
                       }
                       else if (e.getSource()==Button6) {
                         displayTextField.setText("6"); 
                       }
                       else if (e.getSource()==Button7) {
                         displayTextField.setText("7"); 
                       }
                       else if (e.getSource()==Button8) {
                         displayTextField.setText("8"); 
                       }
                       else if (e.getSource()==Button9) {
                         displayTextField.setText("9"); 
                       }
                       else if (e.getSource()==Button0) {
                         displayTextField.setText("0"); 
                       }
                       else if (e.getSource()==astrButton) {
                         displayTextField.setText("*"); 
                       }
                       else if (e.getSource()==boundButton) {
                         displayTextField.setText("#"); 
                       }

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    how can you modify your object just inside the Class, but on method?

  3. #3
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default GUI phone

    hi,
    i change it and its ok now, but i need to display all digits being pressed on the textfield with a message like " calling 345-273-8765" when pressing SEND button. also i need to erase what ever is on the phone display screen and then display a message like (Redialing 765-9864-1234) when pressing REDIAL button ???
    Java Code:
    /**
      This program simulates a cellphone.
    
    */
    
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    
    public class CellPhone extends JFrame {
    
    	private final String WINDOW_TITLE = "CellPhone Simulation";
    	private final int WINDOW_WIDTH = 200; 
    	private final int WINDOW_HEIGHT = 300; 
            String input;
    	
    
    	// The following named controls will appear in our GUI
    
        private JPanel textPanel = new JPanel();
        private JPanel digitPanel = new JPanel();
        private JPanel buttonPanel = new JPanel();
    
        
        private JLabel displayLabel = new JLabel ("                     NOKIA ");
    
        private JTextField displayTextField = new JTextField(20);
        
        private JButton sendButton = new JButton("Send");
        private JButton clearButton = new JButton("Clear");
        private JButton endButton = new JButton(" End ");
        private JButton redialButton = new JButton("Redial");
        private JButton Button1 = new JButton("1");
        private JButton Button2 = new JButton("2");
        private JButton Button3 = new JButton("3");
        private JButton Button4 = new JButton("4");
        private JButton Button5 = new JButton("5");
        private JButton Button6 = new JButton("6");
        private JButton Button7 = new JButton("7");
        private JButton Button8 = new JButton("8");
        private JButton Button9 = new JButton("9");
        private JButton Button0 = new JButton("0");
        private JButton astrButton = new JButton("*");
        private JButton boundButton = new JButton("#");
        
    /** We'll use DecimalFormat later to convert the result to a String with two decimal places.
     */
    
        private DecimalFormat df2 = new DecimalFormat("#,###.00");
    
        /**
          The main method creates an instance of the cellphone class, which displays
          its window on the screen.
        */
    
        public static void main(String[] args) {
            new CellPhone();
        }
    
    /**
        The constructor for this application will initialize the JFrame
        by setting the window title bar, giving the frame a size,
        initializing all the controls that appear on the frame, and
        then make it visible.
     */
        public CellPhone()
        {
    
            setTitle(WINDOW_TITLE);
            setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            buildTextPanel();
            buildButtonPanel();
            buildDigitPanel();
            setLayout(new BorderLayout());
            add(textPanel,BorderLayout.NORTH);
            add(buttonPanel,BorderLayout.CENTER);
            add(digitPanel,BorderLayout.SOUTH);
            clearDisplay();
            setVisible(true);
    
        }
    
    /**
        The buildTextPanel method creates a panel to hold the label and the textfield.
     */
    	public void buildTextPanel () {
    		textPanel.setLayout(new BorderLayout());
    		textPanel.add(displayLabel,BorderLayout.NORTH);
    		textPanel.add(displayTextField,BorderLayout.CENTER);
                    textPanel.setBackground(Color.RED);
    	}
    
    /**
          The buildButtonPanel method creates a panel to hold the send,clear,end and redial buttons.
     */
    	public void buildButtonPanel () {
    		buttonPanel.setLayout(new FlowLayout());
    		buttonPanel.add(sendButton);
    		buttonPanel.add(clearButton);
    		buttonPanel.add(endButton);
                    buttonPanel.add(redialButton);
    		sendButton.addActionListener(new SendButtonListener());
    		clearButton.addActionListener(new ClearButtonListener());
    		endButton.addActionListener(new EndButtonListener());
                    redialButton.addActionListener(new RedialButtonListener());
                    buttonPanel.setBackground(Color.RED);
    	}
    
    /**
          The buildDigitPanel method creates a panel to hold the digit buttons.
     */
    	public void buildDigitPanel () {
    		digitPanel.setLayout(new GridLayout(4,3));
    		digitPanel.add(Button1);
    		digitPanel.add(Button2);
                    digitPanel.add(Button3);
                    digitPanel.add(Button4);
                    digitPanel.add(Button5);
                    digitPanel.add(Button6);
                    digitPanel.add(Button7);
                    digitPanel.add(Button8);
                    digitPanel.add(Button9);
                    digitPanel.add(astrButton);
                    digitPanel.add(Button0);
                    digitPanel.add(boundButton);
    
    /** create innerlistener to all buttons, then add all buttons to 
        this listener. 
     */
                
               InnerListener listener= new InnerListener();
                    Button1.addActionListener(listener);
                    Button2.addActionListener(listener);
                    Button3.addActionListener(listener);
                    Button4.addActionListener(listener);
                    Button5.addActionListener(listener);
                    Button6.addActionListener(listener);
                    Button7.addActionListener(listener);
                    Button8.addActionListener(listener);
                    Button9.addActionListener(listener);
                    Button0.addActionListener(listener);
                    astrButton.addActionListener(listener);
                    boundButton.addActionListener(listener);
    	}
    
        
    
    /**
         SendButtonListener is an action listener class for
          the Send button.
     */
    
    	private class SendButtonListener implements ActionListener {
    /**
          The actionPerformed method executes when the user clicks on the send button.
          @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
                  input= displayTextField.getText();
    	       	sendCalling();
                    
    		}
    	}
    
    /**
         ClearButtonListener is an action listener class for
          the Clear button.
     */
    
    	private class ClearButtonListener implements ActionListener {
    
    /**
         The actionPerformed method executes when the user clicks on the clear button.
          @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
    	       	clearDisplay();
    		}
    	}
    
    /**
        EndButtonListener is an action listener class for the Exit button.
     */
    
    	private class EndButtonListener implements ActionListener {
    /**
        The actionPerformed method executes when the user
         clicks on the end button.
         @param e The event object.
     */
    
          	public void actionPerformed(ActionEvent e) {
    
    	       	endCalling();
    		}
    	}
    
            private class RedialButtonListener implements ActionListener {
    
            public void actionPerformed(ActionEvent e) {
                      input= displayTextField.getText();
                     redialCalling();
                     }
            }
    
       	
    /**
        The clearDisplay method will clear the digit,send,end and redial fields.
     */
    
       	public void clearDisplay() {
    		displayTextField.setText(" ");
    		
    	}
       	
    /**
        The sendCalling method will dislay a message when calling.
     */
            public void sendCalling() {
    		displayTextField.setText("Calling " + input+ input+ input+ "-" + input+ input+input+ "-" +input+ input+ input+ input);
    		
    	}
    /**
        The endCalling method will dislay a message when call is ended.
     */
            public void endCalling() {
    		displayTextField.setText("Call Ended");
    		
    	}
    /**
        The redialCalling method will dislay a message when number is redialing.
     */
            public void redialCalling() {
    		displayTextField.setText("Redialing " + input+ input+ input+ "-" + input+ input+input+ "-" + input+ input+ input+ input );
    		
    	}
    
          
            
            private class InnerListener implements ActionListener {
    
            public void actionPerformed(ActionEvent e) {
                      if(e.getSource()==Button1) {
                        displayTextField.setText("1"); 
                      }
                       else if (e.getSource()==Button2) {
                         displayTextField.setText("2"); 
                       }
                       else if (e.getSource()==Button3) {
                         displayTextField.setText("3"); 
                       }
                       else if (e.getSource()==Button4) {
                         displayTextField.setText("4"); 
                       }
                       else if (e.getSource()==Button5) {
                         displayTextField.setText("5"); 
                       }
                       else if (e.getSource()==Button6) {
                         displayTextField.setText("6"); 
                       }
                       else if (e.getSource()==Button7) {
                         displayTextField.setText("7"); 
                       }
                       else if (e.getSource()==Button8) {
                         displayTextField.setText("8"); 
                       }
                       else if (e.getSource()==Button9) {
                         displayTextField.setText("9"); 
                       }
                       else if (e.getSource()==Button0) {
                         displayTextField.setText("0"); 
                       }
                       else if (e.getSource()==astrButton) {
                         displayTextField.setText("*"); 
                       }
                       else if (e.getSource()==boundButton) {
                         displayTextField.setText("#"); 
                       }
                       
             }       
         }     
     }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    This is off your subject, but with arrays, you could shrink this code by more than half, and make it easier to debug and maintain at the same time.

    Also, even without arrays, your inner listener code can be shrunk to a few lines by using the String returned from the ActionEvent's getActionCommand() method.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    for example, is this easier to read, understand, and modify?
    Java Code:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    
    public class CellPhone2
    {
      // the dial pad button strings
      private static final String[][] BUTTONSTRINGS =
      {
        {"1", "2", "3"},
        {"4", "5", "6"},
        {"7", "8", "9"},
        {"*", "0", "#"}
      };
      private static final Dimension JUNK_SIZE = new Dimension(200, 160);
      private JPanel mainPanel = new JPanel();
    
      public CellPhone2()
      {
        JPanel otherJunkPanel = new JPanel();
        otherJunkPanel.add(new JLabel("Other Junk Goes Up Here"));
        otherJunkPanel.setBackground(Color.red);
        otherJunkPanel.setPreferredSize(JUNK_SIZE);
        
        JPanel dialPadPanel = new JPanel(new GridLayout(0, 3));
        
        // action listener for the number buttons only 
        NumberButtonListener numberBtnListener = new NumberButtonListener();
        // listener for other buttons
        NonNumberButtonListener nonNumberBtnListener = new NonNumberButtonListener();
        for (int i = 0; i < BUTTONSTRINGS.length; i++)
        {
          for (int j = 0; j < BUTTONSTRINGS[i].length; j++)
          {
            String btnString = BUTTONSTRINGS[i][j]; // get the button string from array
            JButton btn = new JButton(btnString); // use it to make button
            
            // if a number button, add the number button's listener
            if ("012345679".contains(btnString))
            {
              btn.addActionListener(numberBtnListener);
            }
            else
            {
              btn.addActionListener(nonNumberBtnListener);
            }
            
            // add buttons to the dial pad 
            dialPadPanel.add(btn); 
          }
        }
        
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
        mainPanel.add(otherJunkPanel);
        mainPanel.add(dialPadPanel);
      }
    
      public JComponent getPanel()
      {
        return mainPanel;
      }
    
      private class NumberButtonListener implements ActionListener
      {
        public void actionPerformed(ActionEvent e)
        {
          String buttonPressedString = e.getActionCommand();
          System.out.println("Number Button Pressed: " + buttonPressedString);
          // TODO finish      
        }
      }
    
      private class NonNumberButtonListener implements ActionListener
      {
        public void actionPerformed(ActionEvent e)
        {
          String buttonPressedString = e.getActionCommand();
          System.out.println("Non-Number Button Pressed: " + buttonPressedString);
          // TODO finish      
        }
      }
    
      private static void createAndShowGUI()
      {
        JFrame frame = new JFrame("CellPhone2 Application");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new CellPhone2().getPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      }
    
      public static void main(String[] args)
      {
        javax.swing.SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            createAndShowGUI();
          }
        });
      }
    }

  6. #6
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default GUI phone

    hi,
    this does not give me what i want and i try to run your program, but i do not find it useful in resolving my problem ?
    everything with my program is ok, i just do not know how to make every digit being pressed appear on the textfield with the format 000-000-0000 and when pressing Send button a message appears with " calling 123-876-9854" for example, and the same with Redial button .
    have you other solutions??

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    you need to change your button action listeners to so that they update a String or StringBuilder object, that every time a button is pressed, the String gets concatenated or StringBuilder gets appended, and you set the text of the JTextField to the new String or StringBuilder object.toString(). Then clear the String or StringBuilder when send or clear pressed. Simple as that.

    And I'm sorry that my other contributions were not appreciated. I will limit other suggestions to you in the future so as not to draw your ire.

  8. #8
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default GUI phone

    please can you show me how??

  9. #9
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default

    sorry if you feel your contribution is not useful, it is useful and it saves much time and space, but i now need other things rather than shrink the code.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by nanna View Post
    please can you show me how??
    and shoot, you probably don't even need a String or StringBuilder/StringBuffer, but could use the JTextField's text as the String. Simple append your text to the JTextField on button press, and clear it with send or clear (but save it in a String for redial if necessary).

    You should have the knowledge necessary to take a stab at this yourself first. Why not do that and then paste your code when done. Don't forget to use code tags so that your code remains pretty and retains its formatting. Good luck.

  11. #11
    nanna is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default GUI phone

    i do use the JTextField as String for SEND button and REDIAL button:
    Java Code:
         String input;
    private class RedialButtonListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
    
                  input= displayTextField.getText();
    	       	sendCalling();
    
    
    private class RedialButtonListener implements ActionListener {
    
            public void actionPerformed(ActionEvent e) {
                      input= displayTextField.getText();
                     redialCalling();

Similar Threads

  1. can i send sms from pc to phone through internet
    By for108 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-30-2010, 12:28 PM
  2. Replies: 0
    Last Post: 06-11-2008, 11:10 AM
  3. Playing Mp3 in a Mobile phone
    By luisarca in forum CLDC and MIDP
    Replies: 1
    Last Post: 06-23-2007, 05:20 PM
  4. Playing Mp3 in a Mobile phone
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 06-21-2007, 10:17 AM
  5. Play sound and Video in a Mobile Phone
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 2
    Last Post: 05-23-2007, 10:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •