Solved

Creating 'help' windows from dialog button

Posted on 1998-04-11
4
173 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
ID: 1234044
  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
ID: 1234045
 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
ID: 1234046
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
ID: 1234047
 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
what is the difference between "sudo su" and "su - root" 6 102
stackato and cloud 4 65
diffSum example 4 21
egit plugin on eclipse 8 31
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

919 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

19 Experts available now in Live!

Get 1:1 Help Now