• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exam tip & a question

Basu Patel
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know if we are provided with a decimal to binary to hexadecimal to octadecimal calculator like the one provided with the windows operating system for the exam.All MCP papers are allowed to use the windows calculator.
Also I have a problem with the following code on java.awt,please refer below,the line: label.setText(s)
import java.awt.*;
import java.awt.event.*;
public class ButtonApp extends Frame {
Label label=new Label("Default Label");
Button b1=new Button("one");
Button b2=new Button("two");
Button b3=new Button("three");
Panel p1=new Panel();
Panel p2=new Panel();
public static void main(String[] args) {
ButtonApp obj=new ButtonApp();
public ButtonApp() {
b1.addActionListener(new ButtonHandler());
b2.addActionListener(new ButtonHandler());
b3.addActionListener(new ButtonHandler());
addWindowListener(new WindowEventHandler());
class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
String s=e.getActionCommand();
/*here my compilor gives me an error saying that 'label' is an undefined variable or class name,please help! */
class WindowEventHandler extends WindowAdapter {
public void windowClosing(WindowEvent e) {

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this.
Remove the } which is after the show() method and place it after System.exit(0).
By doing this you are making the ButtonHandler and WindowEventHandler classes as the inner classes of ButtonApp Class. Now these two classes can access all the fields of ButtonApp.
[This is the whole point behind making inner classes. As a next step try making these two classes as anonymous classes of ButtonApp.]
- Srini

What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!