Programming backspace function in a java calculator.

I am doing a java calculator.
I want to program the backspace function, here is the code I have:
private void jbbackspaceMouseClicked(java.awt.event.MouseEvent evt) {                                        
// TODO add your handling code here:
caja=Float.valueOf(jtfpantalla.getText()).floatValue();
if(caja==0){
jtfpantalla.setText("0");
else{
char caja2;
caja2=Float.toString(caja);
caja2.getChars(0,24,caja2,0);
jtfpantalla.setText(String.valueOf(caja));
Netbeans sends me 2 errors. I don't know how to use caja, as string or as an array. I want to convert it ,to print the characters of the array except the last character when the backspace button will be pressed.
I want to count the decimal point as another character, and print the characters except the last two when the decimal point is the penultime in the array.

I'd suggest that you store the temporary or displayed value in the calculator as a List of characters, or a String, and then don't ever turn it into a number until someone pushes the '=' button.
That's assuming I know what you're doing, which maybe I don't.

Similar Messages

  • Programming Key Functions in Web Dynpro Java

    Hi, "Amigous"
    How can I Programming Key Functions in Web Dynpro Java, like F1, F2, F3...??
    Thanks in advance.
    P:D. I don´t have Swine Flu.

    Hi,
    Please see the below link.
    [http://www.octavia.de/fileadmin/octavia_files/content_bilder/Hauptnavigation/SAP_NetWeaver/WebDynpro/Web_Dynpro_Part_I.pdf]
    Regards
    Krishna

  • How can I call a C program or call a C function in my JAVA code?

    Could I call a C program or a C function in my JAVA code?
    somebody told me that I should define a native() method, but what should I do in this native() method?
    could u give me an example?
    thanks in advance.

    Maybe these will give a clue:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    http://java.sun.com/j2se/1.3/docs/guide/jni/

  • Problem calling program unit function in Forms 6i

    Hi,
    I'm new to programming with Oracle Forms. I have a question that I cannot seem to figure out. In Forms 6i, I have created a program unit function that compiles correctly. The trouble I'm having is calling it and displaying the function's contents into a non-database display item I created. When I run my app, the display item it blank while my other fields populate.
    I first tried to call it in a POST-QUERY trigger but I get an error stating "function cannot be called in SQL." Can you not call a function in a form's trigger? If so, what would be the correct syntax?
    Then I tried to call it in the non-database item's Calculation => Formula (property) by just stating the function_name(parameter). This appears to compile fine too, but still no display at runtime.
    What would be the best way to reference my function to display its contents properly? Does anyone have any examples? Any help would be greatly appreciated. Thank you.

    First, get rid of the
    EXCEPTION WHEN NO_DATA_FOUND
    in your function. Summary queries never raise no_data_found; They just return null.
    Your ":history.consecutive_years := NumberOfYears(:student.id);" is the proper way to call the function. That is what I was trying to tell you with the example: ':Myblock.Item_x := function_name(some_parm);' code
    If your post-query trigger only executes the function, then I think your problem is somewhere else:
    'FRM-40735 POST-QUERY trigger raised unhandled exception' looks like a problem elsewhere.
    Don't know of a good website. Just keep asking here -- somebody is bound to pop in and help you out.
    One more thing: drop this into your form-level on-error trigger. It often helps to find problems:
    -- On-error form-level trigger                                       --*
    DECLARE
      Err_Code NUMBER(5)     := ERROR_CODE;
      Err_Text VARCHAR2(100) := ERROR_TEXT;
      MSG      VARCHAR2(150)
              := SUBSTR('   '||ERROR_TYPE||'-'||TO_CHAR(Err_Code)||': '
                                         ||Err_Text,1,150);
      DBMS_TXT VARCHAR2(500);
    BEGIN
      IF Err_Code IN (40401,40405,     --No changes to save/apply
                      40100,40352) THEN --at first/last record
        MESSAGE(MSG,NO_ACKNOWLEDGE); -- Don't raise Form_Trigger_Failure
      ELSE -- all other messages
        -- check database error message --
        DBMS_TXT := SUBSTR(DBMS_ERROR_TEXT,1,500);
        if  DBMS_TXT is not null
        and substr(DBMS_TXT,5,5)
          not in('00000',
                 '01403') then --1403=no data found
          -- show entire msg, add new_line chars.
          DBMS_TXT := replace(DBMS_TXT,'ORA-',chr(10)||'ORA-');
          DBMS_TXT := replace(DBMS_TXT,' '||chr(10), chr(10));
          -- show MSG and DBMS_TXT both as an alert --
          --PLL_ALERT( ltrim(MSG) || DBMS_TXT );
          Message(ltrim(MSG) || DBMS_TXT );
          Message(' ',no_acknowledge);
          Raise Form_Trigger_Failure;
        else
          Message(MSG);
          Message(' ',no_acknowledge);
          Raise Form_Trigger_Failure;
        End if;
      END IF;
    END; -- end of on-error trigger

  • Help Please Needed for Java Calculator - ActionListener HELP

    Hi. I am constructing a simple Java calculator and need help with the actionlistener and how it could work with my program. I am not too sure how to begin constructing the actionlistener. I would like to know the best and most simple solution to get this program work the way it should, like a real calculator. If anyone can help me, that would be much appreciated.
    package calculator;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class CalculatorGUI extends JFrame implements ActionListener{
    JTextField screen;
    JButton button7;
    JButton button8;
    JButton button9;
    JButton button4;
    JButton button5;
    JButton button6;
    JButton button1;
    JButton button2;
    JButton button3;
    JButton button0;
    JButton add;
    JButton minus;
    JButton multiply;
    JButton divide;
    JButton equals;
    JButton clear;
    private JTextField m_displayField;
    private boolean m_startNumber = true;
    private String m_previousOp = "=";
    private CalculatorLogic m_logic = new CalculatorLogic();
    public CalculatorGUI() {
    CalculatorGUILayout customLayout = new CalculatorGUILayout();
    getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
    getContentPane().setLayout(customLayout);
    screen = new JTextField("textfield_1");
    getContentPane().add(screen);
    button7 = new JButton("7");
    getContentPane().add(button7);
    button7.addActionListener(this);
    button8 = new JButton("8");
    getContentPane().add(button8);
    button8.addActionListener(this);
    button9 = new JButton("9");
    getContentPane().add(button9);
    button9.addActionListener(this);
    button4 = new JButton("4");
    getContentPane().add(button4);
    button4.addActionListener(this);
    button5 = new JButton("5");
    getContentPane().add(button5);
    button5.addActionListener(this);
    button6 = new JButton("6");
    getContentPane().add(button6);
    button6.addActionListener(this);
    button1 = new JButton("1");
    getContentPane().add(button1);
    button1.addActionListener(this);
    button2 = new JButton("2");
    getContentPane().add(button2);
    button2.addActionListener(this);
    button3 = new JButton("3");
    getContentPane().add(button3);
    button3.addActionListener(this);
    button0 = new JButton("0");
    getContentPane().add(button0);
    button0.addActionListener(this);
    add = new JButton("+");
    getContentPane().add(add);
    add.addActionListener(this);
    minus = new JButton("-");
    getContentPane().add(minus);
    minus.addActionListener(this);
    multiply = new JButton("*");
    getContentPane().add(multiply);
    multiply.addActionListener(this);
    divide = new JButton("/");
    getContentPane().add(divide);
    divide.addActionListener(this);
    equals = new JButton("=");
    getContentPane().add(equals);
    equals.addActionListener(this);
    clear = new JButton("Clear");
    getContentPane().add(clear);
    clear.addActionListener(this);
    setSize(getPreferredSize());
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public void actionPerformed(ActionEvent event) {
    public static void main(String args[]) {
    CalculatorGUI window = new CalculatorGUI();
    window.setTitle("Calculator");
    window.pack();
    window.show();
    class CalculatorGUILayout implements LayoutManager {
    public CalculatorGUILayout() {
    public void addLayoutComponent(String name, Component comp) {
    public void removeLayoutComponent(Component comp) {
    public Dimension preferredLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    Insets insets = parent.getInsets();
    dim.width = 421 + insets.left + insets.right;
    dim.height = 494 + insets.top + insets.bottom;
    return dim;
    public Dimension minimumLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    return dim;
    public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    Component c;
    c = parent.getComponent(0);
    if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+8,408,64);}
    c = parent.getComponent(1);
    if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+80,96,56);}
    c = parent.getComponent(2);
    if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+80,96,56);}
    c = parent.getComponent(3);
    if (c.isVisible()) {c.setBounds(insets.left+232,insets.top+80,96,56);}
    c = parent.getComponent(4);
    if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+144,96,56);}
    c = parent.getComponent(5);
    if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+144,96,56);}
    c = parent.getComponent(6);
    if (c.isVisible()) {c.setBounds(insets.left+232,insets.top+144,96,56);}
    c = parent.getComponent(7);
    if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+208,96,56);}
    c = parent.getComponent(8);
    if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+208,96,56);}
    c = parent.getComponent(9);
    if (c.isVisible()) {c.setBounds(insets.left+232,insets.top+208,96,56);}
    c = parent.getComponent(10);
    if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+272,96,56);}
    c = parent.getComponent(11);
    if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+80,72,56);}
    c = parent.getComponent(12);
    if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+144,72,56);}
    c = parent.getComponent(13);
    if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+208,72,56);}
    c = parent.getComponent(14);
    if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+272,72,56);}
    c = parent.getComponent(15);
    if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+336,72,56);}
    c = parent.getComponent(16);
    if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+408,408,72);}
    }

    Yeah, I have a rough idea of what the calculator
    should do, like most people would. Its just that I
    dont know how to implement this in Java. Thats the
    problem. Can anyone provide me with code snippets
    that I can try?No I would rather see you make an effort from what has been discussed here. This is not a Java problem this is a general programming problem.

  • How can we write the excel function =Normsdist() in Java?

    Hi,
    I need to use one function in my java program to compute N(z) . In excel the function is =Normsdist(z). Is there any built-in library function for this in Java? How can I accomplish this? Please give me some solutions...
    Thanks.

    I need to use one function in my java program to
    compute N(z) . In excel the function is
    =Normsdist(z). Is there any built-in library
    function for this in Java? No.
    How can I accomplish
    this? Please give me some solutions...
    Thanks.Write your own, or use a 3rd party library.

  • Java Calculator

    I am relatively new to Java programming and am in a Dilemma. I am trying to develop a Java Calculator GUI and I want to include a "memory" button. Any ideas on how I would implement it.
    It needs to be able to store a record and when" memory total"(another button) is pressed it should add all the figures saved by the "Memory" button.
    Thanks in advance for the help
    Ed

    You don't need a database for that.
    Just use an array of floats.
    Or if you prefer, an ArrayList of Floats.
    You just keep adding to the above to store them.
    When you want to total them then you just iterate through them and add them up.

  • I have a Macbook Air that had some coffee spilled on the keyboard and as a result the plus/equals key is no longer functioning. Can I use a program like Ukelele to reprogram a different key to be my plus/equals key? Can I program a function key? key

    I have a Macbook Air that had some coffee spilled on the keyboard and as a result the plus/equals key is no longer functioning. Can I use a program like Ukelele to re-program another key to do that function? Can I re-program a function key to do this function?

    Water + electronics do not mix.  Something was damaged insode, and the logic board may be corroding as is.
    Take it to a Genius Bar for an evaluation and repair estimate.
    This is accidental damage and not covered by warranty.

  • How to call a C function calling a Java Method from another C function ?

    Hi everyone,
    I'm just starting to learn JNI and my problem is that I don't know if it is possible to call a C function calling a Java Method (or doing anything else with JNI) from another C function.
    In fact, after receiving datas in a socket made by a C function, I would like to create a class instance (and I don't know how to do it too ; ) ) and init this instance with the strings I received in the socket.
    Is all that possible ?
    Thank you very much for your help !

    Hard to understand the question, but by most interpretations the answer is going to be yes.
    You do of course understand that JNI is the "API" that sits between Java and C and that every call between the two must go through that. You can't call it directly.

  • How to get the current function name in java

    How to get the current function name in java.
    In c it is done as
    printf("%s",__func__);
    Thanx in advance.

    j0o wrote:
    System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
    "/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
    "/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
    I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes!

  • Program or Function module to delete data from Open Hub Destination Table

    Hi All,
    Can anybody suggest me a Program or Function module to delete data from Open Hub Destination Table.
    Thanks & Regards,
    Vinay Kumar

    You can simply goto t-code SE14 mention the open hub destination table and Delete data by clicking on "Activate and Adjust database" with radio button "Delete Data".
    Regards,
    Arminder

  • Had to restore my iMac from Time Machine. After the restoration all programs are functioning except my Adobe Creative Suite 4 Design Premium. When I start any program in the suite the error message, "Licensing for this product has stopped working." I rest

    I had to restore my iMac from Time Machine. After the restoration all programs are functioning except my Adobe Creative Suite 4 Design Premium. When I start any program in the suite the error message, "Licensing for this product has stopped working." I restarted the computer and tried again to run Photoshop and the same error message appeared. The message was followed by a message that stated that I needed to contact Adobe technical support and mention Error: 150.30. I need Adobe technical support to provide me a solution for my problem so I can continue using my Adobe products installed on my computer.

    Unfortunately when Adobe products are restored from backup, especial CS4 and especially Mac, it breaks licensing.
    There is a python script included in the license recovery kit that should work if you are familiar with Terminal.
    If not, you must reinstall your CS4 suite.  You don't need to delete your preferences, so it should be the same as before.
    Error "Licensing has stopped working" | Mac OS
    Gene

  • Is there a way to get the calculator from the dashboard to appear along with other programs?  Can anyone recommend a calculator which will work as a stand alone app?

    AS it stands now, in order to use the calculator that comes with the Dashboard, you cannot read from a list of numbers in, lets say, word or excel. The dashboard is full screen and nothing can stand along side it. Is there a way to get the calculator from the dashboard to appear along with other programs?  Can anyone recommend a calculator which will work as a stand alone app?

    there is one, just search with spotlight "Calculator".
    It works great!
    Hope this helps.

  • SQL Statement in Program Unit (function)

    When I tried to create a Program Unit(function) in the Form
    module I have got an error
    message "..identifier "SALES.USER_ADMIN" must be declared.."
    How can I fixed it or may be some suggestions..
    Thank you.
    FUNCTION DEF_USER_STATUS (User_Name VARCHAR2)
    RETURN VARCHAR2
    IS
    Security_Stat VARCHAR2(20);
    BEGIN
    SELECT ALL UPPER(SECURITY_STATUS)
    INTO Security_Stat
    FROM SALES.USER_ADMIN
    WHERE LOGIN_NAME = :GLOBAL.LOGIN_NAME;
    IF NO_DATA_FOUND THEN
    Security_Stat := 'GUEST';
    END IF;
    RETURN Security_Stat;
    END DEF_USER_STATUS;

    Check if you are connected before compiling your function. The other thing you should check is if you have proper GRANTs to access tables under SALES schema.
    Also, IF NO_DATA_FOUND is not the way to handle EXCEPTION. Code it as
    EXCEPTION WHEN NO_DATA_FOUND THEN
    END ;
    Hope this helps.
    Parag Kansara

  • Accessing internal table of main program inside function module...

    I have function module say ZFUNC and main program say ZMAIN and internal table defined as IT_TAB inside ZMAIN but not passed as parameter to Function module ZFUNC.
    If I want to access the field value of IT_TAB of  main program ZMAIN inside ZFUNC during debugging then, I simply put <b>(ZMAIN)IT_TAB-amount</b> in ABAP debugger and then change it when the debugger is inside ZFUNC.
    How can I write code to change the value of internal table of main program in function module ZFUNC instead of doing in debugger ? I guess I have to use some field symbols, but not sure. Please suggest.
    Regards,
    Rajesh.

    Yes, you do need to use a field symbol.  Say for example, you had a internal table called IMARC in your program and you want to access it later in a funciton module, you would do something like this.
      data: xmarc type marc.
      field-symbols: <imarc> type marc_upl_tt.
    * Assign an internal table
      field = '(ZPROGRAM_NAME)IMARC[]'.
      assign (field) to <imarc>.
      loop at <imarc> into xmarc.
        write: / xmarc-matnr, xmarc-werks.
      endloop.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Status light in AP1130 doesn't work!!!!!

    I have a AP1130, it's working fine, except the status light is always green, even when there are clients connect to it through wireless in which case it should be blue. I've upgraded the firmware and the same problem still happens. Does anyone knows

  • Foreign Trade

    Hi Folks, Please advice as to how can one use Re export business process eg. you are receiving goods from one country and reexporting the same to another country.How is this taken care of in Foreign trade component. Look forward to you response. rahu

  • SYSTEM ERROR WHILE OPENING CHECK IN

    I format my C7 recently, After that while opening check in it shows SYSTEM ERROR, The same message shows while opening signal boost . . . Whats a remedy . . ?

  • [NewBie] Not able to connect JPA and Hibernate ?

    Hi, In last few days I have read some tutorial and started doing JPA and Hibernate tutorials. But I am not able to make it work. Can some one please point out what is that I am doing wrong? Here are the details of what I am doing I am using IDE : Ecl

  • Photoshop element 13 crashing after os upgrade on my mac. Told upgrade not compatible, anyone having this problem?

    So yeah... Had an update for OS X Yosemite.  The new "Photo" app was added instead of "iPhoto".  Photoshop Element 13 was working fine before and now when I try to open to pull from either one of my photo files photoshop crashes.  Apple said to conta