Results 1 to 6 of 6
  1. #1
    oltaA is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default calculator using eclipse

    final JButton btn_comma = new JButton(",");
    btn_comma.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    display.setText(display.getText()+btn_comma.getTex t());
    }
    the code ive made for the decimal point, but ex when i make 1/6 i see on the display just 66666...
    haw can i make a max characters=15 on my display?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: calculator using eclipse

    Look at the DecimalFormat class as a way to control the number of digits.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    oltaA is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: calculator using eclipse

    i dont understand how to control the number of digits,, im using eclipse as editor. can u help me :/

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: calculator using eclipse

    Create an instance of the DecimalFormat class and use its format() method to create a String with the desired number of digits.
    Or use the String class's format() method.

    Neither of those solutions require or use an IDE. They both are part of the Java SE classes.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    oltaA is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: calculator using eclipse

    im new to java, can u help me with the code for this part please, i have to write on the action performlistener of the button "," ?

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: calculator using eclipse

    write on the action performlistener of the button
    Take a look at the tutorial: How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: 10-11-2013, 09:26 AM
  2. Need help with + - * / calculator
    By Aconitum in forum New To Java
    Replies: 26
    Last Post: 08-04-2012, 07:13 PM
  3. Calculator Issues In Eclipse
    By youngdemetre in forum New To Java
    Replies: 5
    Last Post: 04-30-2011, 02:28 PM
  4. Calculator
    By water in forum AWT / Swing
    Replies: 4
    Last Post: 09-23-2009, 06:00 AM
  5. help with calculator
    By kalibballer in forum New To Java
    Replies: 8
    Last Post: 04-01-2009, 12:57 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
  •