Solved

Creating 'help' windows from dialog button

Posted on 1998-04-11
4
172 Views
Last Modified: 2010-04-16
Using MS Vis J++, I've created some dialog windows to get user input.  I added 'help' buttons to the dialog windows, but can't figure out how to display help messages without destroying the dialog window.  The way I've tried is to create new dialog boxes with the help messages in them--and these are called from the action method of the original dialog.  The problem is, I can't return to that dialog, and the program hangs after reading the help dialog.  This is part of a big program, so here's a portion of the applet code.  If there is a way to allow returning to the dialog box, or an easier way to do this, please let me know:

//the dialog frame that calls the help frame
class OurFrame extends Frame
{
      private AutoDialog m_autodialog = null;
      private Applet m_parent = null;      
      public DialogData m_data = null;
      private HelpFrame m_frame3 = null;

      public OurFrame(Applet parent)
      {
            super("Input Window #1");
            m_parent = parent;
            setFont(new Font("Arial", Font.PLAIN, 12));

            m_autodialog = new AutoDialog(this);
            m_autodialog.CreateControls();
            show();
      }
      public boolean action(Event event, Object obj)
      {
            Object target = event.target;
            if (target instanceof Button)
            {
                  Button button = (Button)target;
                  String buttonLabel = button.getLabel();
                  
                  if (buttonLabel.compareTo("Help") == 0)
                  {
                        m_frame3 =new HelpFrame();
                        //m_help1 = new help1(this);
                        //m_help1.CreateControls();
                        //hide();
                        m_parent.repaint();
                        
                  }
                  if (buttonLabel.compareTo("OK")== 0)
                  {
                        String sk = m_autodialog.IDC_EDIT2.getText();
                        boolean a1 = m_autodialog.IDC_RADIO1.getState();//false = .05
            
                        int m_k = Integer.parseInt(sk);            
                        m_data = new DialogData(sk,a1);
                        m_parent.repaint();
                  }
                  hide();
                  return true;
            }
            return false;
      }


//The helpFrame class that the above calls when the help button is clicked:
class HelpFrame extends Frame
{
      private help1 m_help1 = null;
      public HelpFrame()
      {
            super("Help");
            setFont(new Font("Arial", Font.PLAIN, 12));

            m_help1 = new help1(this);
            m_help1.CreateControls();
            show();
      }
      public boolean action(Event event, Object obj)
      {
            Object target = event.target;
            if (target instanceof Button)
            {
                  Button button = (Button)target;
                  String buttonLabel = button.getLabel();
                  if (buttonLabel.compareTo("OK")== 0)
                  {
                        //m_parent3.repaint();
                        repaint();                        
                  }
                              
                  hide();
                  return true;
            }
            return false;
      }
}
0
Comment
Question by:imsap
  • 3
4 Comments
 
LVL 6

Expert Comment

by:gadio
Comment Utility
  You haven't said if its an applet or an application. If its an applet, a good idea will be to use the showDocument method to open a new brawser window hith your help, and to write your help in html. This is probably the easiest way of creating a help system.
0
 
LVL 6

Expert Comment

by:gadio
Comment Utility
 I see now by your code that it is an applet, so let me know if this direction is good for you, I'll give you some more info about it.
0
 

Author Comment

by:imsap
Comment Utility
Thanks for the reply.  Actually, I have both an application and applet version.  I also figured out the problem--I left off a "return false" in the call to the help dialogs from the original dialogs.  However, you can have the points if you put in some info about using the ShowDocument to create a new browser page.  This would be helpful for cleaning up my applet output.
0
 
LVL 6

Accepted Solution

by:
gadio earned 100 total points
Comment Utility
 I will give you a sample code:
Say that you want to give a help on an item, and you have a
-----
file: simpleApplet1.java
-----


import java.applet.*;
import java.awt.*;

public class simpleApplet1 extends Applet {
  TextField text;
  Button b;
  String help_item;

  public simpleApplet1() {
        help_item = new String( "help" );
        text = new TextField(20);
        b = new Button("help_me");
        add( b );
        add( text );
  }

  public boolean handleEvent( Event evt ) {
        if( evt.target == b ) {
          try {
                getAppletContext().showDocument(new java.net.URL(getCodeBase(),help_item+".html"), help_item);
          }
          catch ( java.net.MalformedURLException e ){}
          return true;
        }
        return false;
  }

}


file index.html
----

<html>
<applet code=simpleApplet1.class name=app2 width=190 height=145>
</applet>
</html>


file: help.html
----

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>help file</title>
  </head>
  <body>
      <h1>help file</h1>
      <hr>
          This is a help about...
  </body>
</html>


---------
Apart from that I'd like to note that sun has a new API for help system. You can check it out at:
http://java.sun.com/products/javahelp/download_spec.html
This help system should fit both applet and application.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array220 challenge 8 44
@SBGen Method 3 25
Java Server Faces parameter pass? 6 18
Java - Why doesn't this JFrame work 3 14
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now