Win a copy of Modern frontends with htmx this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Exam tip & a question

Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic