Charles Bell
Posts: 519
Nickname: charles
Registered: Feb, 2002
|
|
Re: Pop up link?
|
Posted: Jun 21, 2002 10:20 PM
|
|
import java.applet.*; import java.awt.*; import java.awt.event.*;
public class PopupApplet extends Applet implements ActionListener{ private Frame frame; public void init(){ frame = new Frame(); frame.addWindowListener(new FrameListener()); MenuBar menuBar = new MenuBar(); frame.setMenuBar(menuBar); Menu menu = new Menu("PopUps"); menuBar.add(menu); MenuItem popupItem = new MenuItem("Popup"); menu.add(popupItem); popupItem.addActionListener(this); frame.add(this); frame.setSize(getWidth(),getHeight()); //frame.setLocation(getX() + getWidth()/2- frame.getWidth()/2,getY() + getHeight() -frame.getHeight()); frame.setLocation(getX() ,getY() ); frame.show();
} public void actionPerformed(ActionEvent ae){ if (ae.getActionCommand().compareTo("Popup") == 0){ System.out.println("do pop up"); Window popupWindow = new Window(frame); popupWindow.addWindowListener(new FrameListener()); popupWindow.setSize(getWidth()/2, getHeight()/2); popupWindow.setLocation(getX() +100,getY()+100); Panel panel = new Panel(); panel.add(new Label("Pop ups are fun.")); popupWindow.setBackground(Color.blue); popupWindow.add(panel); popupWindow.show(); } } class FrameListener extends WindowAdapter{ public void windowClosing(WindowEvent we){ frame.hide(); } } }
*************************************
<html> <head> <title>PopupApplet</title> </head>
<body> <applet codebase ="." code="PopupApplet.class" width = "400" height = "200">
</applet>
</body>
</html>
|
|