Results 1 to 2 of 2
  1. #1
    phil028 is offline Member
    Join Date
    Dec 2007
    Rep Power

    Default Help with Multiplication

    i have a text box with the name jTextField1. and am trying to multiply the value that you enter in it by 0.12. im not sure at all of even where to start and what exactly i need to declare.

    therfore if anybody can help me with some example code or formula then that would be a great help because im very new to the java language..


  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    In pseudo code:
    Java Code:
    JTextField textField = new JTextField(12);
    textField.addActionListener(new ActionListener() {
        double factor = 0.12;
        public void actionPerformed(ActionEvent e) {
            // User has pressed return/enter to get here:
            JTextField textField = (JTextField)e.getSource();
            String text = textField.getText();
            // Take care that text is parsable...
            double d = Double.parseDouble(text);
            d *= factor;
    // Add textField to your gui...
    // Or, test with something like:
    JOptionPane.showMessageDialog(null, textField, "", -1);
    // Pretend the user has typed in the value "25"
    // Programmatically we could do it with:
    // User presses the "return/enter" key while
    // textField has the focus (blinking caret)
    // which generates an ActionEvent which is
    // reported to all listeners registered to
    // recieve ActionEvents from/on this textField.

Similar Threads

  1. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 04:44 PM

Posting Permissions

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