cadillac
asked on
Floating Menu Bar (using the java Frame class)
Has anyone created any type of floating menu/toolbar for use with a website? I am trying to develop one by using the java Frame class and adding a Menubar to it. I am trying open up different HTML pages when I click on a particular menu item. It will open an HTML page once, but after that, it no longer will open any HTML pages. Does anyone know what the problem could be? If so, do you know how I could correct it?
Post the code, and I'll take a look at it.
ASKER
/*
A basic extension of the java.awt.Frame class
*/
This is the code for the Frame which contains the menubar and toolbar:
import java.awt.*;
import java.net.URL;
import java.net.MalformedURLExcep tion;
import java.applet.*;
public class OptionFrame extends Frame
{
String path = "file:///C|/VisualCafePro/ BNP Real/";
void Browse_Action(Event event)
{
Component c = this;
while (true) {
if (c == null) {
System.out.println("Null Component");
dispose();
}
if (c instanceof Frame)
break;
c = c.getParent();
}
RegDlg dlg = new RegDlg((Frame)c, false);
}
void Submit_Action(Event event)
{
//openURL(path +"html2.html");
}
void PMT_Action(Event event)
{
//openURL(path +"html3.html");
}
void Help_Action(Event event)
{
//openURL(path +"html4.html");
}
void Online_Action(Event event)
{
//openURL(path +"html5.html");
}
void Close_Action(Event event)
{
this.hide();
}
public OptionFrame()
{
//{{INIT_CONTROLS
setLayout(null);
addNotify();
resize(insets().left + insets().right + 471,insets().top + insets().bottom + 58);
setBackground(new Color(12632256));
toolbar = new symantec.itools.awt.util.T oolBarPane l();
toolbar.setLayout(null);
toolbar.reshape(insets().l eft + -2,insets().top + -4,783,54);
toolbar.setBackground(new Color(12632256));
add(toolbar);
toolbar.setBevelStyle(syma ntec.itool s.awt.util .ToolBarPa nel.BEVEL_ NONE);
btn1 = new java.awt.Button("Browse Projects");
btn1.reshape(0,0,90,21);
btn1.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn1);
btn2 = new java.awt.Button("Submittin g Components");
btn2.reshape(90,0,125,21);
btn2.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn2);
btn3 = new java.awt.Button("Download PMT");
btn3.reshape(215,0,88,21);
btn3.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn3);
btn4 = new java.awt.Button("Online Help");
btn4.reshape(303,0,69,21);
btn4.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn4);
btn5 = new java.awt.Button("Bits and Pieces");
btn5.reshape(372,0,87,21);
btn5.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn5);
setTitle("Object Works Menu Bar");
//}}
//{{INIT_MENUS
menuBar1 = new java.awt.MenuBar();
fileMenu = new java.awt.Menu("File", true);
subMenu = new java.awt.Menu("Open", true);
subMenu.add("Browse Components");
subMenu.add("Submitting Components");
subMenu.add("Download PMT");
subMenu.add("Help/Support" );
subMenu.add("Bits and Pieces Online");
fileMenu.add(subMenu);
fileMenu.addSeparator();
fileMenu.add("Close Menu");
menuBar1.add(fileMenu);
helpMenu = new java.awt.Menu("Help", true);
helpMenu.add("Help Topics");
helpMenu.add("Search");
helpMenu.addSeparator();
helpMenu.add("About");
menuBar1.add(helpMenu);
setMenuBar(menuBar1);
//$$ menuBar1.move(-2,55);
//}}
show();
}
/*public String openURL(String url)
{
URL theURL = null;
try { theURL = new URL(url); }
catch ( MalformedURLException e)
{
System.out.println("Bad URL: " + theURL);
}
theApplet.getAppletContext ().showDoc ument(theU RL);
return url;
}*/
public OptionFrame(String title) {
this();
setTitle(title);
}
public synchronized void show() {
move(50, 50);
super.show();
}
public boolean handleEvent(Event event) {
if (event.id == Event.WINDOW_DESTROY) {
hide(); // hide the Frame
return true;
}
return super.handleEvent(event);
}
public boolean action(Event event, Object arg)
{
if (event.target instanceof MenuItem)
{
String label = (String) arg;
if (label.equalsIgnoreCase("B rowse Components"))
{
Browse_Action(event);
return true;
} else
if (label.equalsIgnoreCase("S ubmitting Components"))
{
Submit_Action(event);
return true;
} else
if (label.equalsIgnoreCase("D ownload PMT"))
{
PMT_Action(event);
return true;
} else
if (label.equalsIgnoreCase("H elp/Suppor t"))
{
Help_Action(event);
return true;
} else
if (label.equalsIgnoreCase("B its and Pieces Online"))
{
Online_Action(event);
return true;
} else
if (label.equalsIgnoreCase("C lose Menu"))
{
Close_Action(event);
return true;
}
}
return super.action(event, arg);
}
//{{DECLARE_CONTROLS
symantec.itools.awt.util.T oolBarPane l toolbar;
java.awt.Button btn1;
java.awt.Button btn2;
java.awt.Button btn3;
java.awt.Button btn4;
java.awt.Button btn5;
//}}
//{{DECLARE_MENUS
java.awt.MenuBar menuBar1;
java.awt.Menu fileMenu;
java.awt.Menu subMenu;
java.awt.Menu helpMenu;
//}}
}
A basic extension of the java.awt.Frame class
*/
This is the code for the Frame which contains the menubar and toolbar:
import java.awt.*;
import java.net.URL;
import java.net.MalformedURLExcep
import java.applet.*;
public class OptionFrame extends Frame
{
String path = "file:///C|/VisualCafePro/
void Browse_Action(Event event)
{
Component c = this;
while (true) {
if (c == null) {
System.out.println("Null Component");
dispose();
}
if (c instanceof Frame)
break;
c = c.getParent();
}
RegDlg dlg = new RegDlg((Frame)c, false);
}
void Submit_Action(Event event)
{
//openURL(path +"html2.html");
}
void PMT_Action(Event event)
{
//openURL(path +"html3.html");
}
void Help_Action(Event event)
{
//openURL(path +"html4.html");
}
void Online_Action(Event event)
{
//openURL(path +"html5.html");
}
void Close_Action(Event event)
{
this.hide();
}
public OptionFrame()
{
//{{INIT_CONTROLS
setLayout(null);
addNotify();
resize(insets().left + insets().right + 471,insets().top + insets().bottom + 58);
setBackground(new Color(12632256));
toolbar = new symantec.itools.awt.util.T
toolbar.setLayout(null);
toolbar.reshape(insets().l
toolbar.setBackground(new Color(12632256));
add(toolbar);
toolbar.setBevelStyle(syma
btn1 = new java.awt.Button("Browse Projects");
btn1.reshape(0,0,90,21);
btn1.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn1);
btn2 = new java.awt.Button("Submittin
btn2.reshape(90,0,125,21);
btn2.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn2);
btn3 = new java.awt.Button("Download PMT");
btn3.reshape(215,0,88,21);
btn3.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn3);
btn4 = new java.awt.Button("Online Help");
btn4.reshape(303,0,69,21);
btn4.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn4);
btn5 = new java.awt.Button("Bits and Pieces");
btn5.reshape(372,0,87,21);
btn5.setFont(new Font("Dialog", Font.PLAIN, 12));
toolbar.add(btn5);
setTitle("Object Works Menu Bar");
//}}
//{{INIT_MENUS
menuBar1 = new java.awt.MenuBar();
fileMenu = new java.awt.Menu("File", true);
subMenu = new java.awt.Menu("Open", true);
subMenu.add("Browse Components");
subMenu.add("Submitting Components");
subMenu.add("Download PMT");
subMenu.add("Help/Support"
subMenu.add("Bits and Pieces Online");
fileMenu.add(subMenu);
fileMenu.addSeparator();
fileMenu.add("Close Menu");
menuBar1.add(fileMenu);
helpMenu = new java.awt.Menu("Help", true);
helpMenu.add("Help Topics");
helpMenu.add("Search");
helpMenu.addSeparator();
helpMenu.add("About");
menuBar1.add(helpMenu);
setMenuBar(menuBar1);
//$$ menuBar1.move(-2,55);
//}}
show();
}
/*public String openURL(String url)
{
URL theURL = null;
try { theURL = new URL(url); }
catch ( MalformedURLException e)
{
System.out.println("Bad URL: " + theURL);
}
theApplet.getAppletContext
return url;
}*/
public OptionFrame(String title) {
this();
setTitle(title);
}
public synchronized void show() {
move(50, 50);
super.show();
}
public boolean handleEvent(Event event) {
if (event.id == Event.WINDOW_DESTROY) {
hide(); // hide the Frame
return true;
}
return super.handleEvent(event);
}
public boolean action(Event event, Object arg)
{
if (event.target instanceof MenuItem)
{
String label = (String) arg;
if (label.equalsIgnoreCase("B
{
Browse_Action(event);
return true;
} else
if (label.equalsIgnoreCase("S
{
Submit_Action(event);
return true;
} else
if (label.equalsIgnoreCase("D
{
PMT_Action(event);
return true;
} else
if (label.equalsIgnoreCase("H
{
Help_Action(event);
return true;
} else
if (label.equalsIgnoreCase("B
{
Online_Action(event);
return true;
} else
if (label.equalsIgnoreCase("C
{
Close_Action(event);
return true;
}
}
return super.action(event, arg);
}
//{{DECLARE_CONTROLS
symantec.itools.awt.util.T
java.awt.Button btn1;
java.awt.Button btn2;
java.awt.Button btn3;
java.awt.Button btn4;
java.awt.Button btn5;
//}}
//{{DECLARE_MENUS
java.awt.MenuBar menuBar1;
java.awt.Menu fileMenu;
java.awt.Menu subMenu;
java.awt.Menu helpMenu;
//}}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.