[nbusers] For Loop, Array, TextArea

  • From: "coderkid" < >
  • To:
  • Subject: [nbusers] For Loop, Array, TextArea
  • Date: Mon, 15 Oct 2012 20:38:32 -0400

I mean that, when the calculateButton is pressed, the code within its 
parameters does not do anything. I realized one mistake within the code (the 
setText line is not within the for loop to put multiple lines of text as the 
loop executes). However, even with the following change, nothing happens when 
I click the calculate button: 

 
public void calculateButtonActionPerformed(java.awt.event.ActionEvent evt)   {

 double userBaseNumber = Double.valueOf(userBaseInputField.getText());
 int userExponentNumber = Integer.valueOf(userExponentInputField.getText());
 String userBaseString = userBaseInputField.getText();
int exponentNumber=1;
String exponentNumberString = Integer.toString(exponentNumber);
        Double exponentNumberDouble = 
Double.parseDouble(exponentNumberString);
for(int i=1;i<=userExponentNumber;i++){

                exponentNumber+=i;
                outputAnswerArea.setText(userBaseString+"to the 
exponent"+exponentNumberString+"equals"+Double.toString(Math.pow(userBaseNumber,exponentNumberDouble)));
        }

Also, when no input is in either inputField, the exit button does not exit 
the system as it should. Instead, the following errors occur: 

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty 
String
        at 
sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
        at java.lang.Double.valueOf(Double.java:504)
        at 
u1a7_powers.U1A7_PowersView.calculateButtonActionPerformed(U1A7_PowersView.java:313)
        at 
u1a7_powers.U1A7_PowersView$3.actionPerformed(U1A7_PowersView.java:57)
        at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
        at 
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
        at 
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at 
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at 
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6505)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
        at java.awt.Component.processEvent(Component.java:6270)
        at java.awt.Container.processEvent(Container.java:2229)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
        at java.awt.Container.dispatchEventImpl(Container.java:2287)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at 
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
        at 
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
        at java.awt.Container.dispatchEventImpl(Container.java:2273)
        at java.awt.Window.dispatchEventImpl(Window.java:2719)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.awt.EventQueue$4.run(EventQueue.java:696)
        at java.awt.EventQueue$4.run(EventQueue.java:694)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
        at 
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
        at 
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
        at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)


But when text is in the input fields, the exit button exits the system as it 
should. Without the calculateButton's code, the exit button also works as it 
should with no input text needed.


What I really need to know, I guess,are three things:
1. Why is nothing appearing in the text area (even though I use the 
textArea.setText("text") command?
2. Why does the exitButton act this way? It works fine in other codes that 
have several buttons. 
3. How can I get my for loop to work properly?






[nbusers] For Loop, Array, TextArea

coderkid 10/14/2012

[nbusers] Re: For Loop, Array, TextArea

Edson Richter 10/15/2012

[nbusers] For Loop, Array, TextArea

coderkid 10/15/2012

[nbusers] Re: For Loop, Array, TextArea

Edson Richter 10/15/2012

[nbusers] For Loop, Array, TextArea

coderkid 10/15/2012

[nbusers] Re: For Loop, Array, TextArea

Edson Richter 10/15/2012

[nbusers] Re: For Loop, Array, TextArea

Bayless Kirtley 10/15/2012

[nbusers] For Loop, Array, TextArea

coderkid 10/16/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close