Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating 'help' windows from dialog button

Posted on 1998-04-11
4
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

704 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