codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Altering Text Fields,  swp_3 at 02:24 on Tuesday, March 22, 2005
 

hello! im fairly new to java and have been trying to resolve this problem for over a week with no joy so i thought i would start asking for help.

Basically this is the problem: the program is a basic calculator, however i cant seem to interact with the textfield i set up called display in order to show calculations or numbers in it. the following is how i create the listener and how i add it:

calculator listener = new calculator();

then further down the code...

button0.addActionListener(listener);


now the actuall listener:

class calculator implements ActionListener
{



public void actionPerformed(ActionEvent event){


if (event.getActionCommand().equals("0"))
{
// screen.println("0");
display.setText("0");
}
}
}

now if you notice the commented line, to print to the screen, that works, so i think that the listener is linked properly its just when i try getting it to show the text in display i get an java.lang.nullpointerexception, not in compilation but when i actually click the button when the programs running.

so it prints to the screen no problem, but not the textfield.

If a full code listing is required please tell me.

any help as soon as possible would be dearly appreciated.

sorry it should also be noted that the action listener is an inner class, the class it resides in is responsible for setting up the interface.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Shopping Cart -
•  Shopping cart
•  Altering Text Fields,
•  how to set up the project in vc ++ for the class with container member data?
•  new guy looking for simple stub app
•  in vc++ 5.0, get a lot of errors when compile, like, C2501: `string` : missing decl-specifiers etc.
•  Re: Zip/Unzip using Asp.Net without using any third party controls.
•  Jtable
•  Newbie Help!


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005